Benjamin Benavides

Benjamin Benavides

22 posts published

Clearing File Associations

# Clear file association for .PDF files $extension = ".pdf" $progId = "" # Remove the file association Remove-Item "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\$extension" -Recurse # Clear the user choice Remove-ItemProperty "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\$extension\UserChoice" -Name ProgId -ErrorAction SilentlyContinue # Set the ProgId to an empty string Set-ItemProperty "HKCU:

Removing user profiles in Windows

#Self elevate powershell to BuiltIn administrator account if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs; exit } #List of the profiles that we need to keep $profilesToKeep='Public','Administrator','Default','NetworkService','LocalService','systemprofile' #Add the profile