Powershell warning when running script

HI,

When I run my powershell script and getting those warning, how do i stop them from appearing?

WARNING: 16:10:30 - *** The namespace for all the model classes will change from
Microsoft.Azure.Management.Monitor.Management.Models to Microsoft.Azure.Management.Monitor.Models in future releases.
WARNING: 16:10:30 - *** The namespace for output classes will be uniform for all classes in future releases to make it
independent of modifications in the model classes.
WARNING: 16:10:30 - The arguments Categories and Timegrains now have aliases Category and Timegrain respectively. The
plural names will be removed in future releases.

Open in new window


Thank you for your help.

Regards,
Kay
Kelly GarciaSenior Systems AdministratorAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Michael B. SmithManaging ConsultantCommented:
The "warning stream" is number 3.  So re-direct that output to $null.

For example:

write-warning "this is warning text" 3>$null

Open in new window

If you are working with a pipeline, that redirection goes BEFORE the pipe symbol, immediately to the right of the cmdlet generating the warning.
oBdACommented:
That's probably from importing the Azure module; just add -WarningAction SilentlyContinue as Import-Module argument.
Works for any cmdlet that writes stuff to the Warning stream.
To suppress warnings for the rest of the script, you can set the $WarningPreference variable to SilentlyContinue.
Or use something like this if you don't want to add the -WarningAction ... all over the place:
$WarningPreference = SilentlyContinue
# Commands with known warnings you want to suppress ...
$WarningPreference = Continue

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.