Powershell – Pagefile configuration

Automatic Pagefile management

Disable AutomaticManagedPagefile
To disable automatic Pagefile managemet, type:

$computersys = Get-WmiObject Win32_ComputerSystem -EnableAllPrivileges
$computersys.AutomaticManagedPagefile = $False

To enable, type::

$computersys = Get-WmiObject Win32_ComputerSystem -EnableAllPrivileges
$computersys.AutomaticManagedPagefile = $True

Change existing Pagefile
To change existing Pagefile configuration, such as initial and maximum, type:

$physicalmem = Get-WmiObject Win32_PhysicalMemory
$pagefile = Get-WmiObject -Query "Select * From Win32_PageFileSetting Where Name='c:\\pagefile.sys'"
$pagefile.InitialSize = [int]($physicalmem.capacity*1.5/1024/1024)
$pagefile.MaximumSize = [int]($physicalmem.capacity*1.5/1024/1024)

Delete and create Pagefile
To delete an existing Pagefile, type:

$pagefile = Get_WmiObject -Query "Select * From Win32_PageFileSetting Where Name='c:\\pagefile.sys'"

To create a new Pagefile, type

Set-WMIInstance -class Win32_PageFileSetting -Arguments @{name="d:\pagefile.sys";InitialSize = 4096;MaximumSize =4096}


In Depth

Tested With
PowerShell 4.0

Categories: Powershell, WMI | Leave a comment

Post navigation

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Blog at WordPress.com.

%d bloggers like this: