7

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

4

1 回答 1

17

这就是我们如何通过 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;
于 2016-06-14T13:36:50.773 回答