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

PowerShellMicrosoft TechnologiesSoftware & Coding

#### Powershell for beginners

15 Lectures 3.5 hours

#### Learning Task Automation using Windows PowerShell

35 Lectures 2.5 hours

#### The Complete PowerShell 7 course: Beginner To Advanced

Most Popular

145 Lectures 12.5 hours

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.

Updated on 05-Oct-2020 11:22:57