Initiate further cleanup measures with PowerShell on Windows?
Yes, you can use PowerShell to perform many more cleanup actions on Windows to free up disk space and optimize the system. Here are some additional options:
1.) Clean up the WinSxS directory with PowerShell
The WinSxS (Windows Side-by-Side) directory stores different versions of system files to avoid compatibility issues, but it can take up a lot of disk space. You can use PowerShell to clean and optimize the directory to save space. Here's how:
1. Start PowerShell as administrator
- Press `Win + X` and select Windows PowerShell (Administrator) or Terminal (Administrator) .
2. Check the status of the WinSxS directory
To determine the size of the directory and potentially freed space, run the following command:
Dism. exe / Online / Cleanup-Image / AnalyzeComponentStore
Explanation :
- Displays the current size of the WinSxS folder.
- Indicates whether a cleanup is recommended.
3. Perform cleanup
To remove old versions and files that are no longer needed:
Dism. exe / Online / Cleanup-Image / StartComponentCleanup
Explanation :
- Removes unnecessary components and files.
- Does not affect current Windows updates.
4. Optional: Completely remove old Windows updates
To delete all old updates that have been replaced by cumulative updates, run:
Dism. exe / Online / Cleanup-Image / StartComponentCleanup / ResetBase
A notice :
- After this step, old updates cannot be uninstalled.
5. Remove unused Windows features
Disable unused features to save additional storage space:
Get-WindowsFeature | Where-Object { $_. Installed -eq $false} | Out-GridView
Select the features you want and uninstall them with:
Disable-WindowsOptionalFeature -FeatureName "FeatureName" -Online
Replace `FeatureName` with the actual name of the feature.
Recommendations
- Create backup : Make sure you have backed up important data before removing files from the system directory.
- Check storage space : After cleaning, you can check the free space again.
2.) Delete temporary files
Delete temporary files created by the system or programs:
Remove-Item -Path "$env:Temp\* " -Recurse -Force
Note: Check the contents of the temp directory first:
Get-ChildItem -Path "$env:Temp" -Recurse
3.) Windows Update cleanup
Clean up old Windows Update files that are no longer needed:
Dism. exe / Online / Cleanup-Image / StartComponentCleanup / ResetBase
Or clear the update cache:
Remove-Item -Path "C:\ Windows\ SoftwareDistribution\ Download\* " -Recurse -Force
4.) Storage space analysis
Check the largest files and folders on your drive:
Get-ChildItem -Path "C:\ " -Recurse | Sort-Object Length -Descending | Select-Object FullName, Length -First 20
5.) Remove old restore points
Delete old system restore points, but keep the last one:
vssadmin delete shadows / all / quiet
6.) Remove unused Windows features
View list of all optional Windows features:
Get-WindowsOptionalFeature -Online
Disable unnecessary features:
Disable-WindowsOptionalFeature -FeatureName "FeatureName" -Online
7.) Empty the trash
Delete all contents of the Recycle Bin:
Clear-RecycleBin -Force
8.) Clear browser cache
For Microsoft Edge (Chromium-based):
Remove-Item -Path "$env:LocalAppData\ Microsoft\ Edge\ User Data\ Default\ Cache\* " -Recurse -Force
9.) Delete specific log files
Windows log files can take up a lot of space. Delete older log files:
Remove-Item -Path "C:\ Windows\ Logs\* " -Recurse -Force
10.) Storage optimization via Storage Sense (automate)
Enable automatic memory optimization:
Start-Process -FilePath "ms-settings:storagepolicies" -Wait
Here you can configure how often temporary files and recycle bin contents should be deleted.
11.) Uninstall unused apps
View list of installed apps:
Get-AppxPackage | Select-Object Name, PackageFullName
Uninstall apps:
Get-AppxPackage -Name "AppName" | Remove-AppxPackage
12.) Clear Prefetch and Delivery Optimization Cache
- Prefetch files:
Remove-Item -Path "C:\ Windows\ Prefetch\* " -Recurse -Force
- Delivery Optimization Cache:
Remove-Item -Path "C:\ Windows\ SoftwareDistribution\ DeliveryOptimization\* " -Recurse -Force
13.) Remove unused user profiles
List of user profiles:
Get-CimInstance -ClassName Win32_UserProfile | Select-Object LocalPath
Delete unused profiles:
Get-CimInstance -ClassName Win32_UserProfile | Where-Object { !$_. Special -and !$_. Loaded } | Remove-CimInstance
14.) Script for complete cleanup
If you want to summarize all the steps in one script, I can write you a PowerShell script. Should I create that for you?
(Image-1) Initiate further cleanup measures with PowerShell on Windows?
FAQ 29: Updated on: 15 January 2025 15:47
Windows
PowerShell ISE Integrated Scripting Environment is a graphical user interface and development environment specifically designed for creating, testing,
The display language in Windows 11, 10, is the display language you have selected, the default language is used by all Windows settings, file explorer,
The command history in PowerShell should be used because it is practical, the integrated command history function is very popular under Windows 11, 10,
In PowerShell you can also change and adapt the font and add more, under Windows 11, 10, and MS Server OS, how is no longer a question 1. Use a
It is quite easy to list user accounts via PowerShell with a small command that works under Windows 11, 10, and MS Server operating systems If you run
It is really easy to find out the SHA256 hash value of a file with PowerShell under Windows 11, 10, or MS Server 1. Get SHA256 checksum via PowerShell
If there are a lot of pending jobs in the print queue, PowerShell can be used to delete all of the print jobs and thus reset everything 1. The command
»» My question is not there in the FAQ
Keywords: powershell, initiate, further, cleanup, measures, with, windows, perform, many, more, actions, free, disk, space, optimize, system, here, some, additional, options, Questions, Answers, Software