This cmdlet is part of the Vexasoft Cmdlet Library. You can download it now or click here to find out more.

Set-Pagefile

Synopsis

Configures pagefile settings on a local or remote computer.

Syntax

  • Set-Pagefile [-Location] [MinSize] [-MaxSize] [-CleanAtShutdown] [-Reboot] [-ComputerName] [-Credential]
  • Set-Pagefile [-Location] [-SystemManaged] [-CleanAtShutdown] [-Reboot] [-ComputerName] [-Credential]

Description

The Set-Pagefile cmdlet is used to set the size and type of the Windows pagefile on a local or remote computer.

Parameters

  • MinSize The minimum size for the pagefile. This parameter must be used if the MaxSize parameter is specified. It cannot be used when the SystemManaged parameter has been specified.
  • MaxSize The maximum size for the pagefile. This parameter must be used if the MinSize parameter is specified. It cannot be used when the SystemManaged parameter has been specified.
  • Location Store the pagefile at this path and filename. Path must be local and in the format 'C:\PagefileDirectory\pagefile.sys'.
  • SystemManaged Allow Windows to manage pagefiles on this computer.
  • CleanAtShutdown Zero the pagefile (overwrite content with zeros) at system shutdown. System shutdown time will be increased by this process.
  • Reboot Reboot the computer so that configuration changes take effect.
  • ComputerName The computer against which to run the cmdlet. By default this parameter will be populated with the name of the local computer.
  • Credential The credentials under which to run the cmdlet. By default this cmdlet will run as the current user. Using this parameter and the Get-PSCredential cmdlet you can specify an alternate set of credentials under which to execute this command.

Inputs

Set-PageFile accepts the output of the Get-Pagefile cmdlet as an input object. In addition, the Location, MinSize, MaxSize and ComputerName parameters each accept pipeline input by property name.

Outputs

Set-PageFile makes changes directly to Windows and does not output any Powershell objects.

Notes

The Set-Pagefile cmdlet requires that the RPC service is started on the computer it is trying to access and that DNS services are available to resolve target host names.

Example 1

This command will set the pagefile on the local computer to a user managed minimum size of 1024MB and a maximum size of 4094MB in the default location:

Set-PageFile -MinSize 1024 -MaxSize 4094

Example 2

This command will set the pagefile on the local computer to a user managed minimum size of 1024MB and a maximum size of 4094MB in the location D:\pagefile.sys:

Set-PageFile -Location D:\Pagefile.sys -MinSize 1024 -MaxSize 4094

Example 3

This command will set a system managed pagefile on remote computer PC01.The pagefile is also set to be wiped clean at shutdown, using the CleanAtShutdown parameter:

Set-PageFile -SystemManaged -Computer PC01 -CleanAtShutdown

Example 4

This command will set the pagefile on the local computer to a user managed minimum size of 1024MB and a maximum size of 4094MB in the default location, and then reboot the computer so that the changes take effect:

Set-PageFile -MinSize 1024 -MaxSize 4094 -Reboot