WMI Query Issue with "ExistingPageFiles" Key RRS feed

  • Question

  • Although this is technically not PowerCLI, the core code uses it to manipulate WMI further down the road.


    I am trying to set the pagefile on all servers from 2008 and above to system on the C: drive only. If I run the following code:

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

    The code works, and in server 2008 there is now a tickbox for "Automatically manage paging file size for all drives" whereas this feature wasnt available in Server 2003.

    This is where my problem states, the following key is available in server 2008 and above:

    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management\ExistingPageFiles

    However I dont know how to query it via WBEMTEST. Does anyone know where it resides?

    If you run the code above however, and you have 2 separate drives that are custom sized then it simply sets both drives to "system managed" which is greyed out and ticks "Automatically manage paging file size for all drives".

    I cannot seem to find any material that will allow me to probe the ExistingPageFiles registry key directly.

    Any help would be greatly appreciated :)

    Friday, July 29, 2016 6:41 AM

All replies

  • wmic computersystem get automaticManagedPagefile

    wmic computersystem where name="<computername>" set AutomaticManagedPagefile=False



    Friday, July 29, 2016 11:30 AM
  • Apologies, I should have explained that I am running a foreach loop that is designed to set this for 90 servers. If I run that command, it will execute locally.

    The AutomaticManagedPagefile setting is purely for the tick box at the very top... technically I want it enabled I simply dont want any legacy drives mentioned in the ExistingPageFiles to take effect which it will do by default :(

    I didnt use it for the remote registry because you cannot authenticate against it, same with WMIC to my knowledge.

    I specifically want to target the ExistingPageFiles registry key using WMI.

    Friday, July 29, 2016 12:20 PM
  • Get-WmiObject Win32_PageFile -Computer <remotepc> -EnableAllPrivileges


    Friday, July 29, 2016 12:29 PM
  • The problem I have is not with getting the details, its changing them.

    Im not certain that is the correct entry, because Server 2003 doesnt have that registry key, but the MOF data exists for it.

    Windows will not allow you to perform:

    $a =Get-WmiObject Win32_PageFile -Computer <remotepc> -EnableAllPrivileges

    I have already tried that and gotten various issues :(

    Friday, July 29, 2016 12:41 PM
  • You are being too vague.  The WMI call reads the registry key if it exists.  If it doesn't exist then it returns nothing.  If WMI is not working then you will have to fix it.  There is no way to script around failing WMI subsystems.

    Remote Registry is disabled by default on most systems.  WMI or CIM are the standard methods to get this.


    Friday, July 29, 2016 1:05 PM
  • Here is a quick way to test your remote registries.

    reg query \\WS701\HKLM\Software\Microsoft

    where WS701 is the nbname of the remote system.


    Friday, July 29, 2016 1:27 PM