When troubleshooting memory issues it sometimes is necessary to change the size of the Windows pagefile to something different that the default settings. In this case I would like the pagefile to have the same size as the amount of physical memory.
(Default Windows pagefile)
To disable „Automatically manage paging file size for all drives“ WMI can be used with the Win32_ComputerSystem
class. I use it with a WMI CmdLet and not a CIM CmdLet as the put
-method does not work with a CIM CmdLet.
$PageFile = Get-WmiObject -Class Win32_ComputerSystem -EnableAllPrivileges
$PageFile.AutomaticManagedPagefile = $false
$PageFile.put() | Out-Null
When the automation is disabled then the pagefile can be configured. In this case I am setting Initial and Maximum size both to the amount of physical memory. All this can be done with CIM and WMI CmdLets.
$PhysicalMemory = Get-CimInstance -ClassName Win32_PhysicalMemory
$PageFileSize = $PhysicalMemory.Capacity/1MB
"Setting PageFile size to $PageFileSize MB..."
$PageFileSet = Get-WmiObject -Class Win32_PageFileSetting
#$PageFileSet
$PageFileSet.InitialSize = $PageFileSize
$PageFileSet.MaximumSize = $PageFileSize
$PageFileSet.Put() | Out-Null
(Windows pagefile custom configuration)
To activate the configuration the server just needs a reboot.
(Windows pagefile custom configuration activated)
No comments:
Post a Comment