Powershell 2: Unable to suppress warning message Powershell 2: Unable to suppress warning message powershell powershell

Powershell 2: Unable to suppress warning message


I've been trying to suppress the warning messages when stopping a service:

WARNING: Waiting for service 'Service Description' to finish stopping...

The following worked for me:

Stop-Service $svc.Name -WarningAction SilentlyContinue


If it's just a warning that cause problem why don't you set in your script $WarningPreference variable ?

PS C:\> $WarningPreference='silentlycontinue'PS C:\> Write-Warning "coucou"PS C:\> $WarningPreference='continue'PS C:\> Write-Warning "coucou"AVERTISSEMENT : coucou


You may be hitting this bug: http://connect.microsoft.com/PowerShell/feedback/details/541500/warning-verbose-and-debug-streams-do-not-respect-action-preferences-the-way-they-should

Anyway, your command should look like:

Set-DistributionGroup -Identity TestGroup -HiddenFromAddressListsEnabled $true