Last active
December 29, 2015 14:49
-
-
Save whatisinternet/7686349 to your computer and use it in GitHub Desktop.
Remove Metro applications
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
#---------------------------- | |
# Filename: MetroRemove.ps1 | |
# Author: Josh Teeter | |
# Date: 2013-05-06 | |
# Version: 1.0.0.5 | |
# Purpose: This will remove metro apps based on a list of applications in a file called Crapps.txt | |
#---------------------------- | |
$Diagnostics = 0 | |
$DumpApps = 0 | |
# | |
# Determine how many apps are installed | |
# | |
$packages = Get-AppxPackage | |
$Precount = $packages.Count | |
# | |
# Get the current execution path | |
# | |
$fullPathIncFileName = $MyInvocation.MyCommand.Definition | |
$currentScriptName = $MyInvocation.MyCommand.Name | |
$currentExecutingPath = $fullPathIncFileName.Replace($currentScriptName, "") | |
# | |
# Get the user folder | |
# | |
$desktopFolder = [Environment]::GetFolderPath("MyDocuments") | |
$logFile = $desktopFolder.ToString() + "\log.txt" | |
# | |
# Read the list of apps to remove from the file | |
# | |
$filePath = $currentExecutingPath.ToString() + "Crapps.txt" | |
$strAppsToRemove = Get-Content $filePath.ToString() | |
if ($DumpApps) { | |
$installedAppsFile = $currentExecutingPath.ToString() + "Installed.txt" | |
Get-AppxPackage >> $installedAppsFile | |
} | |
if($Diagnostics){Get-AppxPackage} | |
# | |
# Loop through each line in the file and check if the app exists and then remove the app if it does | |
# | |
foreach ($i in $strAppsToRemove){ | |
if($Diagnostics){write-host "Searching for: " $i} | |
try{ | |
# | |
# Search for the app | |
# | |
$toRemove = Get-AppxPackage | Where-Object {$_.Name -like "*" + $i + "*" } | |
# | |
# Remove said app | |
# | |
Remove-AppxPackage $toRemove.PackageFullName | |
write-host "Removing: " $toRemove | |
}catch{ | |
if($Diagnostics){write-host "Not Found: " $i} | |
}#endTry | |
}#endForEach | |
$packages = Get-AppxPackage | |
$postCount = $packages.Count | |
write-host "" | |
write-host "-----------------------------------------" | |
write-host "" | |
write-host Number of apps before removal: $Precount | |
write-host Number of apps after removal: $postCount | |
write-host Number of apps removed: ($Precount - $postCount) | |
$AppsRemoved = ($Precount - $postCount) | |
$DateandTime = Get-Date -format yyyy-M-d | |
echo "Number of modern applications removed: $AppsRemoved"| Out-File -Encoding "UTF8" $logFile -Append |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment