Show MenuHide Menu

Tag: Pagefile

PowerShell Function to Set Page File Initial/Maximum Size

October 12, 2011

The PowerShell 2.0 function below, Set-PageFile, sets a page file to the given initial and maximum size.

At first sight this seems to be an easy task – just set the properties InitialSize and MaximumSize accordingly (Win32_PageFileSetting class). The tricky part is that the system won’t let you change any page file setting as long as the system automatically manages these settings. My function takes care of this fact and disables the Win32_ComputerSystem‘s AutomaticManagedPagefile property if necessary.

The function supports PowerShell’s -WhatIf switch. Therefore you can test it safely without any impact.