PowerShell Script to set the size of pagefile.sys

后端 未结 1 833
迷失自我
迷失自我 2021-01-12 09:45

How to set the size of Page File on Windows(pagefile.sys) via PowerShell?

相关标签:
1条回答
  • 2021-01-12 10:17

    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;
    
    0 讨论(0)
提交回复
热议问题