Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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

Using Powershell, how can I check if there is an existing move request for an Exchange mailbox without it throwing up an error?

I need to run this script from code, and I'd rather not check for the error in the code itself, but let the Powershell script handle the logic.

share|improve this question
up vote 1 down vote accepted

Get-MoveRequest -Identity
Should do the trick

share|improve this answer
This will throw up an error. And, I'm running this script from code - which will translate into a RemoteException. This forces me to parse the error message for a specific phrase. I would like the script itself to be able to handle the logic and not propagate an error up to the application itself. – Chris Dwyer Oct 24 '11 at 16:06
Even if it does handle the error, you will probably want to know there was a problem executing the request. RemoteException might be a security issue. Generally does the script work and you are trying to catch exceptions? or does the code not work and you want to resolve it in PS? – MikeAWood Nov 8 '11 at 1:33
Yes, the script works well. The situation is this: when the script runs, there is a chance that someone has already manually created a move request for the mailbox (I can't control this). – Chris Dwyer Nov 8 '11 at 18:04
If there is a manual move request, it should return back the status of that request. Though you might have an issue submitting the move request if one is already pending. Not sure that I can help you. Hopefully someone with more Powershell experience can chiume in and help you. – MikeAWood Nov 9 '11 at 21:51
I see what you are trying to do. You might be able to use a Try/Catch in PS to return a valid "comment" rather than the error. This looks like a pretty good example. Then when you submit the move request, you can just return back a valid statement and skip the error. Maybe something like "request already pending" or some such... – MikeAWood Nov 9 '11 at 22:09

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.