Windows应用程序很烦人,我想删除它们.一直在玩Powershell和脚本,我想知道是否有办法让Powershell循环遍历所有应用并删除它们.
# List of Applications that will be removed $AppsList = "Microsoft.BingTravel","Microsoft.WindowsAlarms","Microsoft.Reader",` "Microsoft.WindowsScan","Microsoft.WindowsSoundRecorder","Microsoft.SkypeApp","Microsoft.BingFoodAndDrink","Microsoft.BingMaps",` "Microsoft.HelpAndTips","Microsoft.BingFinance","Microsoft.ZuneMusic","Microsoft.BingNews","Microsoft.AkypeApp",` "Microsoft.ZuneVideo","Microsoft.BingTravel","Microsoft.BingSports","Microsoft.BingWeather","Microsoft.BingHealthAndFitness",` "Microsoft.Media.PlayReadyClient.2","Microsoft.XBoxLIVEGames","Microsoft.WindowsReadingList","Microsoft.WindowsAlarms" ForEach ($App in $AppsList) { $Packages = Get-AppxPackage | Where-Object {$_.Name -eq $App} if ($Packages -ne $null) { foreach ($Package in $Packages) { Remove-AppxPackage -package $Package.PackageFullName } } $ProvisionedPackage = Get-AppxProvisionedPackage -online | Where-Object {$_.displayName -eq $App} if ($ProvisionedPackage -ne $null) { remove-AppxProvisionedPackage -online -packagename $ProvisionedPackage.PackageName } }
编辑:
我也是从MDT运行它来进行映像部署.
要使用PowerShell删除应用程序,您需要执行两个操作:
要删除已配置的程序包,请使用命令Remove-AppxProvisionedPackage并删除已使用命令Remove-AppxPackage的已安装程序包.
根据Microsoft的说法,Remove-AppxProvisionedPackage cmdlet会从Windows映像中删除应用程序包(.appx).创建新用户帐户时,将不会安装应用程序包.不会从现有用户帐户中删除包.要删除未配置的应用程序包(.appx)或仅删除特定用户的包,请使用Remove-AppxPackage.
因此,如果要完全删除应用程序,请运行以下命令:
> Get-AppXProvisionedPackage -online | Remove-AppxProvisionedPackage -online
> Get-AppXPackage |删除 – AppxPackage