【问题标题】:PowerShell Script to set the size of pagefile.sys用于设置 pagefile.sys 大小的 PowerShell 脚本
【发布时间】:2016-10-15 06:29:17
【问题描述】:

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

【问题讨论】:

    标签: powershell system pagefile


    【解决方案1】:

    这就是我们如何通过 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;
    

    【讨论】:

    • 这比MS has indicated 简单得多。谢谢。
    • 看起来这仅在该驱动器的设置已经存在时才有效(即,如果它们不存在,它不会创建条目)。 -- Microsoft cmdlet 调用 IMO 非常简单。 -- 实现与上述非常相似,但如果对象不存在,则需要额外检查以创建对象,等等。
    • 正如@BrainSlugs83 所说,这仅在设置已经存在时才有效。如果 pagefile.sys 的设置尚不存在,如何设置其大小?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-04
    • 1970-01-01
    • 2016-05-30
    • 2011-07-01
    相关资源
    最近更新 更多