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
Solved

Reducing size of page file on Hyper-V 2012 core

Posted on 2015-01-14
11
668 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
11 Comments
 
LVL 80

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 95

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 38

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
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.

 

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 38

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 38

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 38

Accepted Solution

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

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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
P2000 SAN SAS - RAID5 or RAID50 10 41
NTP problem 24 41
Migrating Roaming Profiles to new server 5 24
Deploying DAG on Exchange 2013 Standard edition 10 50
The article will show you how you can maintain a simple logfile of all Startup and Shutdown events on Windows servers and desktops with PowerShell. The script can be easily adapted into doing more like gracefully silencing/updating your monitoring s…
First I will try to share a design of a Veeam Backup Infrastructure without Direct NFS Access backup. Note: Direct NFS Access backup transport mechanism is only available in Veeam v9 In above I try to design the Veeam Backup flow between i…
In this Micro Tutorial viewers will learn how to restore single file or folder from Bare Metal backup image of their system. Tutorial shows how to restore files and folders from system backup. Often it is not needed to restore entire system when onl…
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…

839 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