问题
How to set the size of Page File on Windows(pagefile.sys) via PowerShell?
回答1:
This is how we can update the size of pagefile.sys via PowerShell:
# PowerShell Script to set the size of pagefile.sys
$computersys = Get-WmiObject Win32_ComputerSystem -EnableAllPrivileges;
$computersys.AutomaticManagedPagefile = $False;
$computersys.Put();
$pagefile = Get-WmiObject -Query "Select * From Win32_PageFileSetting Where Name like '%pagefile.sys'";
$pagefile.InitialSize = <New_Value_For_Size_In_MB>;
$pagefile.MaximumSize = <New_Value_For_Size_In_MB>;
$pagefile.Put();
Execute the script as below:
PS> .\update_pagefile_size.ps1;
来源:https://stackoverflow.com/questions/37813441/powershell-script-to-set-the-size-of-pagefile-sys