Powershell Warnings

Do you know how sometimes you write a script and the output looks lovely, but for some stupid reason a yellow warning message ruins it.

Well my school day learning from today is that you can turn them off!

So lets say I run this

[PS] C:PS>get-mailboxdatabase -server [Server]

Name                 Server       StorageGroup         Recovery
—-                 ——       ————         ——–
SG2DB2               [Server]     SG2                  False
WARNING: Object [Server]SG2SG2DB2 has been corrupted and it is in an
inconsistent state. The following validation errors have occurred:
WARNING: Exchange cannot store database (.edb) files in the root directory.
Please choose another location. The specified file path is ‘J:SG2DB2.edb’.
SG2DB1               [Server]     SG2                  False
WARNING: Object [Server]SG2SG2DB1 has been corrupted and it is in an
inconsistent state. The following validation errors have occurred:
WARNING: Exchange cannot store database (.edb) files in the root directory.
Please choose another location. The specified file path is ‘J:SG2DB1.edb’.
SG1DB1               [Server]     SG1                  False
WARNING: Object [Server]SG1SG1DB1 has been corrupted and it is in an
inconsistent state. The following validation errors have occurred:
WARNING: Exchange cannot store database (.edb) files in the root directory.
Please choose another location. The specified file path is ‘G:SG1DB1.edb’.
SG1DB2               [Server]     SG1                  False
WARNING: Object [Server]SG1SG1DB2 has been corrupted and it is in an
inconsistent state. The following validation errors have occurred:
WARNING: Exchange cannot store database (.edb) files in the root directory.
Please choose another location. The specified file path is ‘G:SG1DB2.edb’.
SG1DB3               [Server]     SG1                  False
WARNING: Object [Server]SG1SG1DB3 has been corrupted and it is in an
inconsistent state. The following validation errors have occurred:
WARNING: Exchange cannot store database (.edb) files in the root directory.
Please choose another location. The specified file path is ‘G:SG1DB3.edb’.

No do this:
[PS] C:PS>$WarningPreference = “SilentlyContinue”
[PS] C:PS>get-mailboxdatabase -server [Server]

Name                 Server       StorageGroup         Recovery
—-                 ——       ————         ——–
SG2DB2               [Server]     SG2                  False
SG2DB1               [Server]     SG2                  False
SG1DB1               [Server]     SG1                  False
SG1DB2               [Server]     SG1                  False
SG1DB3               [Server]     SG1                  False

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: