How to change pagefile settings from custom to system managed using PowerShell?

PowerShellMicrosoft TechnologiesSoftware & Coding

To change the pagefile settings to system managed, we need to set InitialSize and MaximumSize parameters to 0. In the below example, we have E: has custom pagefile, not system managed and we need to convert it to the system managed.

$pagefileset = Gwmi win32_pagefilesetting | where{$_.caption -like 'E:*'}
$pagefileset.InitialSize = 0
$pagefileset.MaximumSize = 0
$pagefileset.Put() | Out-Null

Now when you check the pagefile setting on E: it should be System managed.

To change the settings on the remote computer use -ComputerName parameter in the Get-WmiObject method.

Updated on 05-Oct-2020 11:20:44