Relocate pagefile using powershell
This short guide explains how to set pagefile configuration using powershell.
It may happen to you that you're working on headless systems (or just use remote powershell, because you can) and you want to adjust the location of the pagefile.
Mostly, you'll do this using the UI on the advanced system settings page.
This works fine and is easy to use. Yet it's not that fast as you've to navigate through a ton of popups.
Just as most stuff on windows, the configuration is done using WMI under the hood and can therefore be accessed using scripting languages - in our case powershell.
Configure pagefile using powershell
Setting pagefile configuration using powershell involves accessing WMI to:
- Disable managed pagefile
- Remove current pagefile configuration
- Create a new pagefile configuration
The script looks as follows:
That's it already - as usual you need to reboot for these settings to apply.