0

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.

1 Answer 1

1

Get-MoveRequest -Identity
Should do the trick

http://technet.microsoft.com/en-us/library/dd876924.aspx

6
  • 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
    Oct 24, 2011 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, 2011 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
    Nov 8, 2011 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, 2011 at 21:51
  • 1
    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. blog.usepowershell.com/category/deep-dive/error-handling 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, 2011 at 22:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .