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

Categories: Powershell, WMI | Leave a comment

Post navigation

Leave a comment

Blog at WordPress.com.