PowerShell脚本设置pagefile.sys的大小

时间:2016-06-14 13:26:03

标签: powershell system pagefile

如何通过PowerShell在Windows(pagefile.sys)上设置页面文件的大小?

1 个答案:

答案 0 :(得分:9)

这是我们如何通过PowerShell更新pagefile.sys的大小:

# 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();

执行如下脚本:

PS> .\update_pagefile_size.ps1;