# How to remove pagefile on the specific drive using PowerShell?

PowerShellMicrosoft TechnologiesSoftware & Coding

In this article, we have a pagefile set on E: (System managed) and we need to remove the pagefile from E: So in the below image once we remove it, the pagefile should be “No Paging File”.

To do so using PowerShell, we need to filter the pagefile on a specific drive and need to run the below code.

$pagefileset = Gwmi win32_pagefilesetting | where{$_.caption -like 'E:*'}
\$pagefileset.Delete()

You may want to reboot the server after removing pagefile.

To change the above settings on the remote computer, use -ComputerName parameter in the GetWMIObject class.

Published on 05-Oct-2020 07:13:07