This commit is contained in:
2020-08-17 12:06:41 -04:00
parent 9fa09f26bd
commit 6eb48873e6
455 changed files with 45184 additions and 14 deletions

View File

@@ -0,0 +1,49 @@
function Get-LogDir
{
try
{
$ts = New-Object -ComObject Microsoft.SMS.TSEnvironment -ErrorAction Stop
if ($ts.Value("LogPath") -ne "")
{
$logDir = $ts.Value("LogPath")
}
else
{
$logDir = $ts.Value("_SMSTSLogPath")
}
}
catch
{
$logDir = $env:TEMP
}
return $logDir
}
$logDir = Get-LogDir
Start-Transcript "$logDir\RemoveUserApps.log"
# Get the list of provisioned packages
$provisioned = Get-AppxProvisionedPackage -online
# Check each installed app
$count = 0
for ($i=1; $i -ile 2; $i++) {
# Check each app (two loops just in case there are dependencies that can't be removed until the
# main app is removed)
Get-AppxPackage | ? {$_.SignatureKind -ne 'System'} | ForEach-Object {
$current = $_
$found = $provisioned | ? {$_.DisplayName -eq $current.Name -and $_.Version -eq $current.Version}
if ($found.Count -eq 0)
{
Write-Host "$($current.Name) version $($current.Version) is not provisioned, removing."
Remove-AppxPackage -Package $current.PackageFullName
$count++
}
}
}
Write-Host "Number of apps removed: $count"
Stop-Transcript