Skip to content

Instantly share code, notes, and snippets.

@grenade
Last active September 24, 2015 10:41
Show Gist options
  • Select an option

  • Save grenade/41e90b4ab67d1eb6a39c to your computer and use it in GitHub Desktop.

Select an option

Save grenade/41e90b4ab67d1eb6a39c to your computer and use it in GitHub Desktop.
$m = New-Object Amazon.EC2.Model.BlockDeviceMapping
$m.DeviceName = 'xvdcb'
$m.NoDevice = $true
C:\tmp\disks.ps1
function Set-PagefileSize {
<#
.Synopsis
#>
param (
[int] $initialSize = 1024,
[int] $maximumSize = 1024
)
$pf = Get-WmiObject -Query "Select * From Win32_PageFileSetting Where Name='c:\\pagefile.sys'"
if (($initialSize -ne $pf.InitialSize) -or ($maximumSize -ne $pf.MaximumSize)) {
Write-Log -message ('setting pagefile size: initial: {0} -> {1}, maximum: {2} -> {3}' -f $pf.InitialSize, $initialSize, $pf.MaximumSize, $maximumSize) -severity 'INFO'
$sys = Get-WmiObject Win32_ComputerSystem -EnableAllPrivileges
$sys.AutomaticManagedPagefile = $False
$sys.Put()
$pf.InitialSize = $initialSize
$pf.MaximumSize = $maximumSize
$pf.Put()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment