How to configure virtual memory page file size using PowerShell DSC
Introduction
This script shows how to configure virtual memory page file size using PowerShell DSC.
This DSC resource is provided AS IS, and is not supported through any Microsoft standard support program or service. The ""x" in xSystemVirtualMemory stands for experimental, which means that these resources will be fix forward and monitored by the module owner(s).
Scenarios
During deployment, system administrators will almost always adjust the virtual memory automatically when building machines first. This script can help admins to leverage PowerShell DSC feature to achieve unified management.
Script
Step1: To install DSC Resource Module, you need to unzip the content under $env:ProgramFiles\WindowsPowerShell\Modules folder
Then, you can confirm installation to run Get-DSCResource and to see that all the resources on this page are among the DSC Resources list.
Details
The properties of xSystemVirtualMemory resource include:
Renaming Requirements
When making changes to these resources, we suggest the following practice:
1. Update the following names by prefixing your company/community name and replacing the "x" with "c" (short for "Community") or another prefix of your choice:
2. Update module and metadata information in the module manifest
3. Update any configuration that uses these resources
Versions
1.0.0.0
Example
Example: Set the virtual memory paging file on drive letter “C”.
This configuration will set the custom size of virtual memory paging file on drive letter “C”.
PowerShellEdit|RemovepowershellConfiguration AdjustVirtualMemory { Param ( #Target nodes to apply the configuration [String[]]$ComputerName = $env:COMPUTERNAME ) Import-DSCResource -ModuleName xSystemVirtualMemory Node $ComputerName { xSystemVirtualMemory AdjustVirtualMemoryExample { ConfigureOption = "CustomSize" InitialSize = 1000 MaximumSize = 2000 DriveLetter = "C:" } } } AdjustVirtualMemory Start-DscConfiguration -Path .\AdjustVirtualMemory -Wait -Force -VerboseConfiguration AdjustVirtualMemory { Param ( #Target nodes to apply the configuration [String[]]$ComputerName = $env:COMPUTERNAME ) Import-DSCResource -ModuleName xSystemVirtualMemory Node $ComputerName { xSystemVirtualMemory AdjustVirtualMemoryExample { ConfigureOption = "CustomSize" InitialSize = 1000 MaximumSize = 2000 DriveLetter = "C:" } } } AdjustVirtualMemory Start-DscConfiguration -Path .\AdjustVirtualMemory -Wait -Force -Verbose
Example: Set the virtual memory paging file to system managed size.
This configuration will set the virtual memory paging file to system managed size on drive letter “C”.
PowerShellEdit|RemovepowershellConfiguration AdjustVirtualMemory { Param ( #Target nodes to apply the configuration [String[]]$ComputerName = $env:COMPUTERNAME ) Import-DSCResource -ModuleName xSystemVirtualMemory Node $ComputerName { xSystemVirtualMemory AdjustVirtualMemoryExample { ConfigureOption = "SystemManagedSize" DriveLetter = "C:" } } } AdjustVirtualMemory Start-DscConfiguration -Path .\AdjustVirtualMemory -Wait -Force -VerboseConfiguration AdjustVirtualMemory { Param ( #Target nodes to apply the configuration [String[]]$ComputerName = $env:COMPUTERNAME ) Import-DSCResource -ModuleName xSystemVirtualMemory Node $ComputerName { xSystemVirtualMemory AdjustVirtualMemoryExample { ConfigureOption = "SystemManagedSize" DriveLetter = "C:" } } } AdjustVirtualMemory Start-DscConfiguration -Path .\AdjustVirtualMemory -Wait -Force -Verbose
Prerequisite
This DSC resource requires the latest version of PowerShell (v4.0, which ships in Windows 8.1 or Windows Server 2012R2). To easily use PowerShell 4.0 on older operating systems, install WMF 4.0 . Please read the installation instructions that are present on both the download page and the release notes for WMF 4.0.