diff --git a/Invoke-FixMemoryManagement/Invoke-FixMemoryManagement.ps1 b/Invoke-FixMemoryManagement/Invoke-FixMemoryManagement.ps1 new file mode 100644 index 0000000..da51347 --- /dev/null +++ b/Invoke-FixMemoryManagement/Invoke-FixMemoryManagement.ps1 @@ -0,0 +1,89 @@ +function Invoke-FixMemoryManagement { +<# +.Synopsis +Check and fix PoolUsageMemory registry value + +.DESCRIPTION +This function checks the value of PoolUsageMaximum in the registry, if it is higher than the PoolUsageMaximum parameter it will be set to 60 + +.NOTES +Name : Invoke-FixMemoryManagement +Author : Jaap Brasser +Version : 1.0 +DateCreated : 2017-04-25 +DateUpdated : 2017-04-25 +Blog : http://www.jaapbrasser.com + +.LINK +http://www.jaapbrasser.com + +.PARAMETER ComputerName +The computer to which will be connected + +.EXAMPLE +.\Invoke-FixMemoryManagement.ps1 + +Description +Dot source the function to memory of the current PowerShell session + +.EXAMPLE +Invoke-FixMemoryManagement -PoolUsageMaximum 70 -Verbose + +Description +Checks if PoolUsageMaximum is set to 70 or higher, if that is the case it will set it to 60 on the local system + +.EXAMPLE +Invoke-FixMemoryManagement -ComputerName server01,server02 + +Description +Checks if PoolUsageMaximum is set to default value 70 or higher, if that is the case it will set it to 60 for server01 and 02 +#> + + + [CmdletBinding(SupportsShouldProcess=$true)] + param( + [Parameter(ValueFromPipeline = $true, + ValueFromPipelineByPropertyName = $true, + Position = 0 + )] + [string[]] $ComputerName = $env:COMPUTERNAME, + + [Parameter( + Position = 1 + )] + [int] $PoolUsageMaximum = 80 + ) + + begin { + $RegistryLocation = 'System\CurrentControlSet\Control\Session Manager\Memory Management\' + $SelectProperty = @{ + Property = @('ComputerName','PoolUsageMaximum','Changed') + } + } + + process { + foreach ($Computer in $ComputerName) { + $HashProperty = @{ + ComputerName = $Computer + PoolUsageMaximum = $null + Changed = $false + } + $RegBase = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive]::LocalMachine,$Computer) + if ($RegBase) { + $CurrentRegKey = $RegBase.OpenSubKey($RegistryLocation,$true) + if ($CurrentRegKey) { + $HashProperty.PoolUsageMaximum = $CurrentRegKey.GetValue('PoolUsageMaximum') + if ($HashProperty.PoolUsageMaximum -ge $PoolUsageMaximum) { + if ($PSCmdlet.ShouldProcess($Computer,('Setting PoolUsageMaximum to: 60'))) { + $CurrentRegKey.SetValue('PoolUsageMaximum',60,[Microsoft.Win32.RegistryValueKind]::DWord) + $HashProperty.Changed = $true + } + } + }get- + } + + New-Object -TypeName PSCustomObject -Property $HashProperty | + Select-Object @SelectProperty + } + } +} \ No newline at end of file diff --git a/New-ZeroFile/New-ZeroFile.ps1 b/New-ZeroFile/New-ZeroFile.ps1 new file mode 100644 index 0000000..44cb52b --- /dev/null +++ b/New-ZeroFile/New-ZeroFile.ps1 @@ -0,0 +1,40 @@ +function New-ZeroFile { +<# +.SYNOPSIS +Retrieves Storage Sense options in Windows 10 + +.DESCRIPTION +This function can retrieve Storage Sense options in Windows 10 + +.PARAMETER Force +Overwrites an existing file if the specified path already exists + +.PARAMETER Path +The path and file name of the zero file that will be created + + + +.NOTES +Name: New-ZeroFile +Author: Jaap Brasser +DateCreated: 2017-01-26 +DateUpdated: 2017-01-26 +Version: 1.0.0 +Blog: http://www.jaapbrasser.com + +.LINK +http://www.jaapbrasser.com + +.EXAMPLE +New-ZeroFile + +Description +----------- +Retrieves all storage sense configuration and recently cleaned data from the current system +#> + + param( + + ) + +} \ No newline at end of file