2626
2727. NOTES
2828 Author: Richard Tracy
29- Last Update:05/30 /2019
30- Version: 1.1.5
29+ Last Update:06/5 /2019
30+ Version: 1.1.6
3131 Thanks to: unixuser011,W4RH4WK,TheVDIGuys,cluberti
3232
3333. EXAMPLE
4949 https://github.com/cluberti/VDI/blob/master/ConfigAsVDI.ps1
5050
5151 .LOG
52+ 1.1.6 - Jun 5, 2019 - Fixed Remove-AppxPackage for AllUsers
5253 1.1.5 - May 30, 2019 - defaulted reg type to dword if not specified, standarized registry keys captalizations
5354 1.1.4 - May 29, 2019 - fixed FOD issue and messages. fixed set-usersettings default users; fixed office detection
5455 resolved all VSC problems
@@ -1101,6 +1102,7 @@ If($RemoveAppxPackages)
11011102
11021103$p = 1
11031104$c = 0
1105+ $d = 0
11041106# Loop through the list of appx packages
11051107foreach ($App in $AppArrayList ) {
11061108
@@ -1110,49 +1112,57 @@ If($RemoveAppxPackages)
11101112 }
11111113else {
11121114# Gather package names
1113- $AppPackageFullName = Get-AppxPackage - Name$App.Name | Select-Object - ExpandProperty PackageFullName
1115+ $AppPackageDetails = Get-AppxPackage - AllUsers - Name$App.Name
11141116
1115- $AppProvisioningPackageName = Get-AppxProvisionedPackage - Online| Where-Object {$_.DisplayName -like $App .Name }| Select-Object - ExpandProperty PackageName
1117+ $AppProvisioningPackageName = Get-AppxProvisionedPackage - Online| Where-Object {$_.DisplayName -like $AppPackageDetails .Name }| Select-Object - ExpandProperty PackageName
11161118
11171119# Attempt to remove AppxPackage
1118- if ($null -ne $AppPackageFullName ) {
1119- Show-ProgressStatus - Message (" Removing application package: {0}" -f $App .Name )- Step$p - MaxStep$AppArrayList.count
1120+ if ($null -ne $AppPackageDetails ) {
1121+ Show-ProgressStatus - Message (" Removing application package: {0}" -f $AppPackageDetails .Name )- Step$p - MaxStep$AppArrayList.count
11201122
11211123try {
1122- Remove-AppxPackage - Package$AppPackageFullName - ErrorAction Stop| Out-Null
1124+ Remove-AppxPackage - AllUsers - Package$AppPackageDetails .PackageFullName - ErrorAction Stop| Out-Null
11231125
1124- Write-LogEntry - Message (" Successfully removed application package: {0}" -f $App .Name )- Outhost
1126+ Write-LogEntry - Message (" Successfully removed application package: {0}" -f $AppPackageDetails .PackageFullName )- Outhost
11251127$c ++
11261128 }
11271129catch [System.Exception ] {
1128- Write-LogEntry - Message (" Failed removing AppxPackage: {0}" -f $_.Message )- Severity3 - Outhost
1130+ Write-LogEntry - Message (" Failed removing AppxPackage: {0}" -f $_ )- Severity3 - Outhost
1131+ }
1132+ Finally {
1133+ Write-LogEntry - Message (" --------------------------------------------------" )- Outhost
11291134 }
11301135 }
11311136else {
1132- Write-LogEntry - Message (" Unable to locate AppxPackage for app: {0}" -f $App .Name )- Outhost
1137+ Write-LogEntry - Message (" Unable to locate AppxPackage for app: {0}" -f $AppPackageDetails .Name )- Outhost
11331138 }
11341139
11351140# Attempt to remove AppxProvisioningPackage
1136- if ($null -eq $AppProvisioningPackageName ) {
1137- Write-LogEntry - Message (" Removing applicationprovisioning package: {0}" -f $AppProvisioningPackageName )
1141+ if ($null -ne $AppProvisioningPackageName ) {
1142+ Write-LogEntry - Message (" Removing applicationPROVISIONED package: {0}" -f $AppProvisioningPackageName )
11381143try {
11391144Remove-AppxProvisionedPackage - PackageName$AppProvisioningPackageName - Online- ErrorAction Stop| Out-Null
1140- Write-LogEntry - Message (" Successfully removed application provisioning package: {0}" -f $AppProvisioningPackageName )- Outhost
1145+ Write-LogEntry - Message (" Successfully removed application PROVISIONED package: {0}" -f $AppProvisioningPackageName )- Outhost
1146+ $d ++
11411147 }
11421148catch [System.Exception ] {
1143- Write-LogEntry - Message (" Failed removing Appx Provisioning Package: {0}" -f $_.Message )- Severity3 - Outhost
1149+ Write-LogEntry - Message (" Failed removing Appx PROVISIONED Package: {0}" -f $_ )- Severity3 - Outhost
1150+ }
1151+ Finally {
1152+ Write-LogEntry - Message (" --------------------------------------------------" )- Outhost
11441153 }
11451154 }
11461155else {
1147- Write-LogEntry - Message (" Unable to locate AppxProvisioning Package for app: {0}" -f $App .Name )- Outhost
1156+ Write-LogEntry - Message (" Unable to locate AppxPROVISIONED Package for app: {0}" -f $AppPackageDetails .Name )- Outhost
11481157 }
11491158
11501159 }
11511160
11521161$p ++
11531162 }
11541163
1155- Write-LogEntry - Message (" Removed {0} built-in AppxPackage and AppxProvisioningPackage" -f $c )- Outhost
1164+ Write-LogEntry - Message (" Removed {0} All Users App Package's" -f $c )- Outhost
1165+ Write-LogEntry - Message (" Removed {0} built-in App PROVISIONED Package's" -f $d )- Outhost
11561166}
11571167Else {$stepCounter ++ }
11581168