Software-OK
≡... News | ... Home | ... FAQ | Impressum | Contact | Listed at | Thank you |

  
HOME ► Faq ► FAQ - PowerShell ► ««« »»»

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
2. Delete temporary files
3. Windows Update cleanup
4. Storage space analysis
5. Remove old restore points
6. Remove unused Windows features
7. Empty the trash
8. Clear browser cache
9. Delete specific log files
10. Storage optimization via Storage Sense (automate)
11. Uninstall unused apps
12. Clear Prefetch and Delivery Optimization Cache
13. Remove unused user profiles
14. Script for complete cleanup








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?
Initiate further cleanup measures with PowerShell on Windows?


-
▲ Back to the top ▲







FAQ 29: Updated on: 15 January 2025 15:47 Windows
PowerShell

What is PowerShell_ISE and what is it for on Windows?


PowerShell ISE Integrated Scripting Environment is a graphical user interface and development environment specifically designed for creating, testing,
PowerShell

Quickly change the Windows 11, 10, ... language with PowerShell!


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,
PowerShell

How can I use the command history in Windows PowerShell?


The command history in PowerShell should be used because it is practical, the integrated command history function is very popular under Windows 11, 10,
PowerShell

Customize the font in PowerShell and add more fonts, but how?


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
PowerShell

Can I list user accounts through PowerShell?


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
PowerShell

How can I find out the SHA hash value of a file using PowerShell?


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 
PowerShell

Reset print queue with 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
Asked questions on this answer:
Keywords: powershell, initiate, further, cleanup, measures, with, windows, perform, many, more, actions, free, disk, space, optimize, system, here, some, additional, options, Questions, Answers, Software




  

  + Freeware
  + Order on the PC
  + File management
  + Automation
  + Office Tools
  + PC testing tools
  + Decoration and fun
  + Desktop-Clocks
  + Security

  + SoftwareOK Pages
  + Micro Staff
  + Freeware-1
  + Freeware-2
  + Freeware-3
  + FAQ
  + Downloads

  + Top
  + Desktop-OK
  + The Quad Explorer
  + Don't Sleep
  + Win-Scan-2-PDF
  + Quick-Text-Past
  + Print Folder Tree
  + Find Same Images
  + Experience-Index-OK
  + Font-View-OK


  + Freeware
  + DesktopDigitalClock
  + ClassicDesktopClock
  + PreventTurnOff
  + QuickMemoryTestOK
  + IsMyHdOK
  + AutoPowerOptionsOK
  + OneLoupe
  + TraceRouteOK
  + GetWindowText
  + PAD-s


Home | Thanks | Contact | Link me | FAQ | Settings | Windows 10 | gc24b | English-AV | Impressum | Translate | PayPal | PAD-s

 © 2025 by Nenad Hrg softwareok.de • softwareok.com • softwareok.com • softwareok.eu


► How many different RAM modules are there worldwide? ◄
► How do I create columns in Microsoft Word? ◄
► Create multiple guest accounts on Windows 11, 10, 8.1, MS Server with commands? ◄
► Is my Office 365 / 2016 activated, how can I see it? ◄


This website does not store personal data. However, third-party providers are used to display ads,
which are managed by Google and comply with the IAB Transparency and Consent Framework (IAB-TCF).
The CMP ID is 300 and can be individually customized at the bottom of the page.
more Infos & Privacy Policy

....