fix the issue

This commit is contained in:
2024-01-04 09:13:26 -05:00
parent 5b43b97ce2
commit 9153541837
+38 -9
View File
@@ -55,20 +55,49 @@ If ( IsWindowsBuild -ge 9200 )
ForEach ( $App in $AppList ) {
# Get the full name for the package and provisioned package
$PackageFullName = $($(Get-AppxPackage $App).PackageFullName)
$ProPackageFullName = $($(Get-AppxProvisionedPackage -Online | Where-Object {$_.Displayname -eq $App}).PackageName | Select-Object -First 1)
$ProPackageFullName = $($(Get-AppxProvisionedPackage -Online | Where-Object {$_.Displayname -eq $App}).PackageName)
# If the package exists, uninstall it
# Make sure we have a package
If ($PackageFullName) {
Write-Output Removing package: ${PackageFullName}
Try { Remove-AppxPackage -Package $PackageFullName }
Catch { Write-Error $_.Exception.Message }
# Test if the package is an array
If ( $PackageFullName -is [System.Array] ) {
# Iterate through the array of packages and uninstall each one
ForEach ( $package in $PackageFullName ) {
Write-Output Removing package: ${package}
Try { Remove-AppxPackage -Package $package }
Catch { Write-Error $_.Exception.Message }
}
# If it's not an array, just uninstall the package
} Else {
Write-Output Removing package: ${PackageFullName}
Try { Remove-AppxPackage -Package $PackageFullName }
Catch { Write-Error $_.Exception.Message }
}
}
# If the provisioned package exists, uninstall it
# Make sure we have a provisioned package
If ($ProPackageFullName) {
Write-Output Removing provisioned package: ${ProPackageFullName}
Try { Remove-AppxProvisionedPackage -PackageName $ProPackageFullName -Online -AllUsers }
Catch { Write-Error $_.Exception.Message }
# Test if the provisioned package is an array
If ( $ProPackageFullName -is [System.Array] ) {
# Iterate through the array of provisioned packages and uninstall each one
ForEach ( $propackage in $ProPackageFullName ) {
Write-Output Removing provisioned package: ${propackage}
Try { Remove-AppxProvisionedPackage -PackageName $propackage -Online -AllUsers }
Catch { Write-Error $_.Exception.Message }
}
# If it's not an array, just uninstall the provisioned package
} Else {
Write-Output Removing provisioned package: ${ProPackageFullName}
Try { Remove-AppxProvisionedPackage -PackageName $ProPackageFullName -Online -AllUsers }
Catch { Write-Error $_.Exception.Message }
}
}
}
} Else { Write-Output "Cannot remove Appx packages because this endpoint is not running Windows 8 or higher" }