Remove Windows Server Disabled Roles and Features Payload Files

microsoft black logo

Last updated on March 30th, 2023 at 05:07 pm

Read Time:1 Minute, 20 Second

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.

Feedback

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]

Free Subscription

If you want to be notified when we post more quality guides like this one, sign up to our free subscription service and you will receive an email when a new post is live.

Join 441 other subscribers.

No need to worry, we will not be filling your inbox with spam and you can unsubscribe anytime you like.


Leave us a message...

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