Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to run Exchange 2010 cmdlets such as this one:

Get-Mailbox UserName -ErrorVariable err

However, the cmdlets seem to completely ignore the -ErrorVariable parameter: the variable $err is never created or modified, regardless of the command's success or failure.

Why is this happening, and how can I make them work like they should (i.e. populating the variable with the actual command result)?

This works perfectly on Exchange 2007, or with any other cmdlet which isn't specific to Exchange 2010.

share|improve this question
up vote 3 down vote accepted

After googling for a while and finding lots of people sharing the same problem, I opened a support call with Microsoft. They told me to use globally-scoped variables instead of standard ones, and everything started working as expected:

Get-Mailbox UserName -ErrorVariable global:err

This is, of course, mentioned absolutely nowhere in the product documentation (as of today; I sincerely hope they are going to update it after my support call).

The same behaviour also applies to -OutVariable: OutVariable is broken for Exchange 2010 cmdlets.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.