Handling Warnings in Powershell
Posted on 2012-03-22
I have been attempting to do some maintenance on thousands of exchange mailboxes and would like to base a statement on one of the warnings returned by the get-mailboxstatistics cmdlet. I'm running get-mailboxstatistics -warningvariable X -identity <alias> | select lastlogontime,storagelimitstatus. I'm getting the warning "The user hasn't logged on to mailbox '<alias>' (big long SID), so ther is no data to return. After the user logs on, this warning will no longer appear." I would like to trap this warning and use it for decision making in my script but I can't seem to get it into the warning variable. Any suggestions?