0

I need help with Powershell this is my code;

$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"
    }
}

and this is what i see Path : Online : True

Disabled Optional Feature Printing-PrintToPDFServices-Features

Path : Online : True

Disabled Optional Feature Printing-XPSServices-Features

Path : Online : True

Disabled Optional Feature WCF-Services45

Path : Online : True

Disabled Optional Feature MediaPlayback

Path : Online : True

I just Want to Hide Path : Online : True And ThankYOU

Sycho
  • 23
  • 1
  • 5

1 Answers1

2

Suppress the output from Disable-WindowsOptionalFeature by piping to Out-Null, or by assigning it to the automatic $null variable:

Disable-WindowsOptionalFeature -Online -FeatureName $Feature -NoRestart |Out-Null
# or
$null = Disable-WindowsOptionalFeature -Online -FeatureName $Feature -NoRestart
Mathias R. Jessen
  • 157,619
  • 12
  • 148
  • 206