Created
September 16, 2021 12:12
-
-
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
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
# 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