Skip to content

Instantly share code, notes, and snippets.

@rosshiga
Created January 16, 2023 00:12
Show Gist options
  • Select an option

  • Save rosshiga/8ea75520714479a8ff6055484fb44164 to your computer and use it in GitHub Desktop.

Select an option

Save rosshiga/8ea75520714479a8ff6055484fb44164 to your computer and use it in GitHub Desktop.
Remove Ms Office Temporary Owner Files ~$
$SourceDir = "C:\"
foreach ($file in Get-ChildItem -Force $SourceDir -Recurse)
{
if ((($file.Extension -match ".doc") -or ($file.Extension -match ".xls"))-and ($file.Name -like "~$*"))
{
Remove-Item $file.FullName -Force
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment