Skip to content

Instantly share code, notes, and snippets.

@le717
Created September 16, 2021 12:12
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 le717/ad127a28dba4517d6a41415a54068127 to your computer and use it in GitHub Desktop.
Save le717/ad127a28dba4517d6a41415a54068127 to your computer and use it in GitHub Desktop.
Powershell script to find and delete MS Word's Normal.dotm template file
# Get a link to the root AppData folder
$appdata = $(Join-Path -Path $(Resolve-Path ~) -ChildPath "AppData")
Write-Host "Searching for Normal.dotm in $($appdata)"
Write-Host "This may take some time..."
# Search for the Normal.dotm file
$results = Get-ChildItem -Path $appdata -Filter Normal.dotm -Recurse -ErrorAction SilentlyContinue -Force
# It found the file
if ($results -ne $null) {
# Get a full path to it
$normal_file = Join-Path -Path $results.Directory -ChildPath $results.Name
# Prompt to delete the file
Remove-Item -Confirm -Force -Path $normal_file
# We couldn't find the file
} else {
Write-Host "Could not find Normal.dotm file"
Start-Sleep -Seconds 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment