Skip to content

Instantly share code, notes, and snippets.

@jdferrell3
Created March 4, 2020 00:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jdferrell3/f2d0b4e9381387eca86cead427d5e138 to your computer and use it in GitHub Desktop.
Save jdferrell3/f2d0b4e9381387eca86cead427d5e138 to your computer and use it in GitHub Desktop.
# remove files that match a specified hash
$PATH = "c:\testing"
$HASH = "39DD73E4DAE46B506E7F9B41066F7F21E5D61DADD4D2B5806D31E364886C2D08"
$files = Get-ChildItem -Path $PATH -File
ForEach ($f in $files)
{
$fullpath = "$PATH\$f"
$hashInfo = Get-FileHash $fullpath -Algorithm SHA256
if ($hashInfo.Hash -eq $HASH)
{
Write-Host "Removing $fullpath"
Remove-Item -Path $fullpath
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment