我正在尝试编写自己的去臃肿脚本,该脚本将从 Windows 10 中删除预配置应用程序和用户应用程序。我使用此命令列出了预配置应用程序,Get-AppXProvisionedPackage -Online | Select DisplayName
并将其过滤掉以显示每个应用程序的显示名称。在下面的代码中,我尝试将每个列出的应用程序放入下面的命令中,因此我必须多次将其写出。有人能解释一下我哪里做错了吗?
PS:我对 PowerShell 还很陌生。
# This script de-bloats unwanted apps from Windows 10.
# To keep certain apps insert a '#' at the beginning of the line
# and it will be skipped from being removed.
Write-Output "Uninstalling provisioned apps"
$ProvisionedApps = @(
"Microsoft.BingWeather"
#"Microsoft.DesktopAppInstaller"
"Microsoft.GetHelp"
"Microsoft.Getstarted"
#"Microsoft.HEIFImageExtension"
"Microsoft.Messaging"
"Microsoft.Microsoft3DViewer"
"Microsoft.MicrosoftOfficeHub"
"Microsoft.MicrosoftSolitaireCollection"
#"Microsoft.MicrosoftStickyNotes"
"Microsoft.MixedReality.Portal"
#"Microsoft.MSPaint"
#"Microsoft.Office.OneNote"
"Microsoft.OneConnect"
"Microsoft.People"
"Microsoft.Print3D"
"Microsoft.ScreenSketch"
#"Microsoft.SkypeApp"
#"Microsoft.StorePurchaseApp"
#"Microsoft.VP9VideoExtensions"
"Microsoft.Wallet"
#"Microsoft.WebMediaExtensions"
#"Microsoft.WebpImageExtension"
#"Microsoft.Windows.Photos"
#"Microsoft.WindowsAlarms"
#"Microsoft.WindowsCalculator"
#"Microsoft.WindowsCamera"
"microsoft.windowscommunicationsapps"
"Microsoft.WindowsFeedbackHub"
#"Microsoft.WindowsMaps"
#"Microsoft.WindowsSoundRecorder"
#"Microsoft.WindowsStore"
"Microsoft.Xbox.TCUI"
"Microsoft.XboxApp"
"Microsoft.XboxGameOverlay"
"Microsoft.XboxGamingOverlay"
"Microsoft.XboxIdentityProvider"
"Microsoft.XboxSpeechToTextOverlay"
"Microsoft.YourPhone"
"Microsoft.ZuneMusic"
"Microsoft.ZuneVideo"
)
foreach ($app in $ProvisionedApps) {
Write-Output "REMOVING $app"
Get-AppXProvisionedPackage -Online | Where-Object DisplayName -EQ $ProvisionedApps | Remove-AppxProvisionedPackage -Online
}
非常感谢
将要
答案1
您可以参考以下详细的 PowerShell 脚本 Windows10-Unbloating-v1.ps1。
实际使用的代码(我将变量名改为你的)是:
foreach ($app in $ProvisionedApps) {
Get-AppxPackage -Name $app -AllUsers | Remove-AppxPackage -AllUsers
Get-AppXProvisionedPackage -Online | Where-Object DisplayName -EQ $app | Remove-AppxProvisionedPackage -Online
}
您会注意到Get-AppXProvisionedPackage
命令中使用了
$app
变量而不是$ProvisionedApps
。