Skip to content

Instantly share code, notes, and snippets.

@msoler8785
Created December 19, 2023 14:22
Show Gist options
  • Save msoler8785/c0abab944225bdf636fceb9a1eb8e879 to your computer and use it in GitHub Desktop.
Save msoler8785/c0abab944225bdf636fceb9a1eb8e879 to your computer and use it in GitHub Desktop.
Disk Cleanup Script
# Delete all the Recycle Bins
Get-ChildItem -Path 'C:\$Recycle.Bin\' -Recurse -Hidden | Remove-Item -Force -Recurse -Verbose
# Delete all User Profiles on computer except active profiles.
# Warning! this will delete all documents and files under the user profile.
$profiles = Get-WMIObject -class Win32_UserProfile | Where-Object { $_.Special -eq $false -and $_.Status -eq 0 -and $_.Loaded -eq $false }
$profiles | Remove-WmiObject
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment