Skip to content

Instantly share code, notes, and snippets.

@DarkCat09
Created October 11, 2022 07:22
Show Gist options
  • Save DarkCat09/1dd3bf89fd175ec73bd8d91c4479a0ff to your computer and use it in GitHub Desktop.
Save DarkCat09/1dd3bf89fd175ec73bd8d91c4479a0ff to your computer and use it in GitHub Desktop.
Removing useless UWP applications
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 }
Function GrantPermissions ([String]$directory)
{
takeown /f $directory
icacls $directory /grant *S-1-3-4:F /c /l
}
GrantPermissions -directory "C:\Program Files\WindowsApps"
Function DeleteUwpPackages ([String]$pkgname, [String]$pkgsearchquery)
{
echo ""
echo "Delete $pkgname [y/n]?"
$delpackage=Read-Host
if ($delpackage.ToLower().Equals("y"))
{
Get-AppxPackage $pkgsearchquery | grep PackageFullName | set uwppackagestodel
try
{
set uwppackagestodel $uwppackagestodel.Split("`n")
}
catch
{
echo "Error"
}
foreach ($uwppackagetodel in $uwppackagestodel)
{
$uwppackagetodel=$uwppackagetodel.Substring(20)
Remove-AppxPackage $uwppackagetodel
GrantPermissions -directory "C:\Program Files\WindowsApps\$uwppackagetodel"
Remove-Item -Recurse "C:\Program Files\WindowsApps\$uwppackagetodel"
}
}
}
DeleteUwpPackages -pkgname "Microsoft Edge" -pkgsearchquery *edge*
DeleteUwpPackages -pkgname "TV and Video" -pkgsearchquery *zunevideo*
DeleteUwpPackages -pkgname "Groove Music" -pkgsearchquery *zunemusic*
DeleteUwpPackages -pkgname "Bing Services (News, Weather...)" -pkgsearchquery *bing*
DeleteUwpPackages -pkgname "Maps" -pkgsearchquery *maps*
DeleteUwpPackages -pkgname "YourPhone" -pkgsearchquery *windowsphone*
DeleteUwpPackages -pkgname "Get Started" -pkgsearchquery *getstarted*
DeleteUwpPackages -pkgname "Get Help" -pkgsearchquery *gethelp*
DeleteUwpPackages -pkgname "3D Builder" -pkgsearchquery *3dbuilder*
DeleteUwpPackages -pkgname "MS Solitare Collection" -pkgsearchquery *solitare*
DeleteUwpPackages -pkgname "Xbox Apps" -pkgsearchquery *xbox*
DeleteUwpPackages -pkgname "OneNote" -pkgsearchquery *onenote*
DeleteUwpPackages -pkgname "Office" -pkgsearchquery *officehub*
DeleteUwpPackages -pkgname "Skype" -pkgsearchquery *skypeapp*
DeleteUwpPackages -pkgname "People" -pkgsearchquery *people*
DeleteUwpPackages -pkgname "Calendar and Mail" -pkgsearchquery *communicationsapps*
DeleteUwpPackages -pkgname "Camera" -pkgsearchquery *camera*
DeleteUwpPackages -pkgname "Sound Recorder" -pkgsearchquery *soundrecorder*
DeleteUwpPackages -pkgname "Photos" -pkgsearchquery *photos*
DeleteUwpPackages -pkgname "Alarms and Clock" -pkgsearchquery *alarms*
DeleteUwpPackages -pkgname "Calculator" -pkgsearchquery *calculator*
GrantPermissions -directory "C:\Program Files\WindowsApps\Deleted"
Remove-Item -Recurse "C:\Program Files\WindowsApps\Deleted"
Pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment