Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

1 Answer 1

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

 
discard

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.