Solved

Reducing size of page file on Hyper-V 2012 core

Posted on 2015-01-14
11
744 Views
Last Modified: 2015-04-08
Hi Experts, need to reduce page file size on Hyper-V hosts in a cluster. Have moved all VMs to one host and trying to run the following which completes successfully:

PS C:\> wmic computersystem set AutomaticManagedPagefile=false
Updating property(s) of '\\VMHOST\ROOT\CIMV2:Win32_ComputerSystem.Name="VMHOST"'
Property(s) update successful.

But when I try to run the following I get the error message below:
PS C:\> wmic pagefileset where name=”C:\\pagefile.sys” set InitialSize=1024,MaximumSize=3096
Invalid format.
Hint: <assignlist> = <propertyname>=<propertyvalue> [, <assignlist>].

Am running in powershell from console as Administrator. Thanks
0
Comment
Question by:abhijitm00
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
11 Comments
 
LVL 81

Expert Comment

by:David Johnson, CD, MVP
ID: 40550207
found this http://bit.ly/1IywMOa
function Set-PageFile
{
    <#
    .SYNOPSIS
        Sets Page File to custom size
 
    .DESCRIPTION
        Applies the given values for initial and maximum page file size.
 
    .PARAMETER Path
        The page file's fully qualified file name (such as C:\pagefile.sys)
 
    .PARAMETER InitialSize
        The page file's initial size [MB]
 
    .PARAMETER MaximumSize
        The page file's maximum size [MB]
 
    .EXAMPLE
        C:\PS> Set-PageFile "C:\pagefile.sys" 4096 6144
    #>
 
    [CmdletBinding(SupportsShouldProcess=$True)]
    param (
        [Parameter(Mandatory=$true,Position=0)]
        [ValidateNotNullOrEmpty()]
        [String]
        $Path,
        [Parameter(Mandatory=$true,Position=1)]
        [ValidateNotNullOrEmpty()]
        [Int]
        $InitialSize,
        [Parameter(Mandatory=$true,Position=2)]
        [ValidateNotNullOrEmpty()]
        [Int]
        $MaximumSize
    )
     
    Set-PSDebug -Strict
 
    $ComputerSystem = $null
    $CurrentPageFile = $null
    $Modified = $false
 
    # Disables automatically managed page file setting first
    $ComputerSystem = Get-WmiObject -Class Win32_ComputerSystem -EnableAllPrivileges
    if ($ComputerSystem.AutomaticManagedPagefile)
    {
        $ComputerSystem.AutomaticManagedPagefile = $false
        if ($PSCmdlet.ShouldProcess("$($ComputerSystem.Path.Server)", "Disable automatic managed page file"))
        {
            $ComputerSystem.Put()
        }
    }
 
    $CurrentPageFile = Get-WmiObject -Class Win32_PageFileSetting
    if ($CurrentPageFile.Name -eq $Path)
    {
        # Keeps the existing page file
        if ($CurrentPageFile.InitialSize -ne $InitialSize)
        {
            $CurrentPageFile.InitialSize = $InitialSize
            $Modified = $true
        }
        if ($CurrentPageFile.MaximumSize -ne $MaximumSize)
        {
            $CurrentPageFile.MaximumSize = $MaximumSize
            $Modified = $true
        }
        if ($Modified)
        {
            if ($PSCmdlet.ShouldProcess("Page file $Path", "Set initial size to $InitialSize and maximum size to $MaximumSize"))
            {
                $CurrentPageFile.Put()
            }
        }
    }
    else
    {
        # Creates a new page file
        if ($PSCmdlet.ShouldProcess("Page file $($CurrentPageFile.Name)", "Delete old page file"))
        {
            $CurrentPageFile.Delete()
        }
        if ($PSCmdlet.ShouldProcess("Page file $Path", "Set initial size to $InitialSize and maximum size to $MaximumSize"))
        {
            Set-WmiInstance -Class Win32_PageFileSetting -Arguments @{Name=$Path; InitialSize = $InitialSize; MaximumSize = $MaximumSize}
        }
    }
}

Open in new window

0
 
LVL 96

Expert Comment

by:Lee W, MVP
ID: 40550255
On Hyper-V Server, you should leave the pagefile set to system managed.

Reference: http://www.aidanfinn.com/?p=15659
That said, you should also review the Technet blog on the subject of Pagefile size for Hyper-V guests and hosts:
http://blogs.technet.com/b/mghazai/archive/2011/05/26/what-s-the-story-of-pagefile-size-on-hyper-v-servers.aspx

Finally, if you still want to set it manually, try running the WMIC in a command prompt and NOT in a POWERSHELL prompt.
0
 
LVL 39

Assisted Solution

by:Philip Elder
Philip Elder earned 500 total points
ID: 40550474
We set all Hyper-V servers whether standalone or clustered to 4192MB Min/Max.

wmic.exe computersystem where name="SERVERNAME" set AutomaticManagedPagefile=False
wmic.exe pagefileset where name="c:\\pagefile.sys" set InitialSize=4199,MaximumSize=4199
1.      Reboot
2.      Dir /as in C:\
      Swap File should be 4GB.
0
Edgartown IT Case Study

Learn about Edgartown's quest to ensure the safety and security of the entire town's employee and citizen data. Read the case study!

 

Author Comment

by:abhijitm00
ID: 40551940
Thanks for replying.

Philip, on trying your commands the first command worked. Running the second I get:
ERROR:
Description = Value out of range

I have tried changing values for initial and maximum size but still get the same error
0
 
LVL 39

Expert Comment

by:Philip Elder
ID: 40552034
Could you post a snip of the two commands being run including the error please?
0
 

Author Comment

by:abhijitm00
ID: 40552181
C:\Users\>wmic.exe computersystem where name="SERVERNAME" set Automat
icManagedPagefile=False
Updating property(s) of '\\VMHOST\ROOT\CIMV2:Win32_ComputerSystem.Name="VMHOST"
Property(s) update successful.

C:\Users\>wmic.exe pagefileset where name="c:\\pagefile.sys" set InitialSize=4192,MaximumSize=8092
Updating property(s) of '\\VMHOST\ROOT\CIMV2:Win32_PageFileSetting.Name="C:\\pagefile.sys"'
ERROR:
Description = Value out of range
0
 
LVL 39

Expert Comment

by:Philip Elder
ID: 40552201
Change SERVERNAME to your server's name. Sorry if that wasn't clear. :(
0
 

Author Comment

by:abhijitm00
ID: 40552205
Sorry you were quite clear and that command did work as below:

C:\Users\>wmic.exe computersystem where name="VMHOST" set AutomaticManagedPagefile=False
Updating property(s) of '\\VMHOST\ROOT\CIMV2:Win32_ComputerSystem.Name="VMHOST"'
Property(s) update successful.
0
 
LVL 39

Accepted Solution

by:
Philip Elder earned 500 total points
ID: 40552222
Swapfile SuccessWorking for me?
0
 
LVL 39

Expert Comment

by:Philip Elder
ID: 40552225
Something just tweaked in the grey matter. The "C:\\Pagefile.sys" may need caps as I have it here or just one or the other capitalized.
0
 

Author Comment

by:abhijitm00
ID: 40552300
No had it correct the first time "C:\pagefile.sys"
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
A procedure for exporting installed hotfix details of remote computers using powershell
In this Micro Tutorial viewers will learn how they can get their files copied out from their unbootable system without need to use recovery services. As an example non-bootable Windows 2012R2 installation is used which has boot problems.
This tutorial will walk an individual through the process of configuring basic necessities in order to use the 2010 version of Data Protection Manager. These include storage, agents, and protection jobs. Launch Data Protection Manager from the deskt…

690 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question