我需要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"
}
}这就是我所看到的路径:在线:真
禁用可选功能打印-PrintToPDFServices-功能
路径: Online : True
禁用可选功能打印.XPSServices.特性
路径: Online : True
禁用可选功能WCF-Services45 45
路径: Online : True
禁用可选功能MediaPlayback
路径: Online : True
我只想隐藏路径: Online : True和ThankYOU
发布于 2021-12-28 16:47:16
通过管道传递到Disable-WindowsOptionalFeature或将其分配给自动$null变量,从而抑制来自$null的输出:
Disable-WindowsOptionalFeature -Online -FeatureName $Feature -NoRestart |Out-Null
# or
$null = Disable-WindowsOptionalFeature -Online -FeatureName $Feature -NoRestarthttps://stackoverflow.com/questions/70509985
复制相似问题