Created
November 27, 2018 01:02
-
-
Save mjsqu/1df68e5224598b5ada11cccddfd9347a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Grab files from your user profile | |
# -Force - gets hidden files | |
# -ErrorAction - suppresses errors associated with permissions | |
# PSISContainer is only true for folders - so only pick where false | |
$files = Get-ChildItem $env:USERPROFILE -Recurse -Force -ErrorAction SilentlyContinue | Where-Object {$_.PSISContainer -eq $false} | |
Write-Host "Total User Profile takes up: {0} KB" -f [int]$($($files | Measure-Object -sum Length).Sum/1024) | |
# Display an Out-GridView showing the top $n files | |
$n = 20 | |
$deletelist = $files | Sort-Object Length -Descending | Select-Object FullName, Length -First $n | Out-GridView -PassThru | |
# Delete the files selected | |
ForEach ($file in $deletelist) { | |
Remove-Item $file.FullName | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment