Question

I'm scripting a check for pagefile status utilizing PowerShell. On Windows 2000/2003 machines a user can choose between 3 pagefile options via the windows virtual Memory dialog:

  • Custom Size
  • System Managed Size
  • No paging file

I can successfully determine which of these options are selected by doing a:

$PageFileInfo = Get-WmiObject Win32_PageFileSetting  -ComputerName .
  • Custom Size - returns $PageFileInfo.MaximumSize that is non-zero
  • System Managed Size - returns $PageFileInfo.MaximumSize that is zero
  • No paging file - returns null for $PageFileInfo

My issue is that on a Windows 2008 server, there is a 4th option:

  • Automatically manage paging file size for all drives

and unfortunately, in this instance $PageFileInfo returns null, just as if No Paging file was selected.

I've attempted utilizing the following, all which return null on my test 2008 server when Automatically manage paging file size for all drives is selected:

  • Get-WmiObject Win32_PageFileSetting -ComputerName .
  • Get-WmiObject Win32_PageFile -ComputerName .
  • Get-WmiObject -Query 'SELECT * FROM meta_class WHERE __this ISA "Win32_PageFileSetting"'

How can I determine when Automatically manage paging file size for all drives is selected? am I going about this in a sane manner?

Any advice would be appreciated.

Was it helpful?

Solution

Automatically managed page file settings are reached via Win32_ComputerSystem class. The Win32_PageFileUsage class has interesting data as well. A blog article has more information and a neat example.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top