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

Remove-Pagefile

Synopsis

Removes a pagefile set on a local or remote computer.

Syntax

  • Remove-Pagefile [-Location] [-Reboot] [-ComputerName] [-Credential]

Description

The Remove-Pagefile cmdlet is used to remove a Windows pagefile on a local or remote computer.

Parameters

  • Location The pagefile to remove. Path must be local and in the format 'C:\PagefileDirectory\pagefile.sys'.
  • 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

Remove-Pagefile accepts the output of Get-Pagefile as an input object. The ComputerName and Location parameters each accept pipeline input by property name.

Outputs

Remove-Pagefile makes changes directly to Windows and does not output any Powershell objects.

Notes

The Remove-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:

Remove-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:

Remove-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:

Remove-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:

Remove-Pagefile -MinSize 1024 -MaxSize 4094 -Reboot