microsoft black logo

If you are running a Windows Server environment and you are becoming increasing low on system drive space, then you may want to consider removing the built in payload files for Windows Features.

Windows Server comes with the payload files readily available if you want to add any additional Features or Roles to your server. This means that the installation will be a bit quicker as the server will have no requirement to go to the internet to download the payload files.

However, these payload files can take up a signification amount of disk space, so if you are looking to reclaim some disk space, you can use this PowerShell command to remove any disabled roles and features payload files:

PowerShell Script

Simply open up an elevated PowerShell prompt on the server yu wih to remove the payload files from and run this script below:

Get-WindowsOptionalFeature -Online | where { $_.State -match "Disabled" } |
foreach { $_ = $_.FeatureName; 
DISM /Online /Disable-Feature /FeatureName:$_ /Remove

This will now go through your server and find all the disabled roles and features. It will then pass on that information to a looping DISM command and will remove all of the payload files that are disabled.

You should find that you will free up at least around 2GB of disk space.


We would love to hear your feedback on this guide, did it help you out or did you run into any trouble or errors?

If so, please feel free to leave us a message below in the comments section and we will get back to you as soon as we can.

Click to rate this post!
[Total: 0 Average: 0]

Discover more from TechyGeeksHome

Subscribe to get the latest posts to your email.

Avatar for Andrew Armstrong

Andrew Armstrong

Founder of TechyGeeksHome and Head Editor for over 15 years! IT expert in multiple areas for over 26 years. Sharing experience and knowledge whenever possible! Making IT Happen.

Leave us a message...

This site uses Akismet to reduce spam. Learn how your comment data is processed.