Powershell – Pagefile configuration


Automatic Pagefile management

Disable AutomaticManagedPagefile
To disable automatic Pagefile managemet, type:

$computersys = Get-WmiObject Win32_ComputerSystem -EnableAllPrivileges
$computersys.AutomaticManagedPagefile = $False
$computersys.Put()

To enable, type::

$computersys = Get-WmiObject Win32_ComputerSystem -EnableAllPrivileges
$computersys.AutomaticManagedPagefile = $True
$computersys.Put()

 
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)
$pagefile.Put()

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

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

To create a new Pagefile, type

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

 

In Depth
http://myitforum.com/myitforumwp/2013/06/12/pagefile-manual-or-windows-managed/
http://blogs.metcorpconsulting.com/tech/?p=188
http://mitchyb.blogspot.com.es/2013/11/page-file-manipulation-using-powershell.html

Tested With
PowerShell 4.0

Advertisements
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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: