无声的进步?电源外壳

Silent Progress ? PowerShell

我需要 Powershell 方面的帮助 这是我的代码;

$Features = @(
    "MediaPlayback"
    "Printing-PrintToPDFServices-Features"
    "Printing-XPSServices-Features"
    "SMB1Protocol"
    "WCF-Services45"
    "Xps-Foundation-Xps-Viewer"
    )

Foreach ($Feature in (Get-WindowsOptionalFeature -Online).FeatureName) {
    If ($Feature -in $Features) {
        Disable-WindowsOptionalFeature -Online -FeatureName $Feature -NoRestart
        Write-Host "Disabled Optional Feature $Feature"
    }
}

这就是我看到的 小路 : 在线:真

已禁用可选功能 Printing-PrintToPDFServices-Features

路径: 在线:真

已禁用可选功能打印-XPSServices-功能

路径: 在线:真

禁用可选功能 WCF-Services45

路径: 在线:真

禁用可选功能 MediaPlayback

路径: 在线:真

我只想躲起来 小路 : 在线:正确 谢谢你

通过管道传输到 Out-Null 或将其分配给自动 $null 变量来抑制 Disable-WindowsOptionalFeature 的输出:

Disable-WindowsOptionalFeature -Online -FeatureName $Feature -NoRestart |Out-Null
# or
$null = Disable-WindowsOptionalFeature -Online -FeatureName $Feature -NoRestart