function Remove-WinUtilAPPX { <# .SYNOPSIS Removes all APPX packages that match the given name .PARAMETER Name The name of the APPX package to remove .EXAMPLE Remove-WinUtilAPPX -Name "Microsoft.Microsoft3DViewer" #> param ( $Name ) try { Write-Host "Removing $Name" Get-AppxPackage "*$Name*" | Remove-AppxPackage -ErrorAction SilentlyContinue Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like "*$Name*" | Remove-AppxProvisionedPackage -Online -ErrorAction SilentlyContinue } catch [System.Exception] { if ($psitem.Exception.Message -like "*The requested operation requires elevation*") { Write-Warning "Unable to uninstall $name due to a Security Exception" } else { Write-Warning "Unable to uninstall $name due to unhandled exception" Write-Warning $psitem.Exception.StackTrace } } catch { Write-Warning "Unable to uninstall $name due to unhandled exception" Write-Warning $psitem.Exception.StackTrace } }