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.

Chris
  • 135
  • 6

1 Answers1

1

Get-MoveRequest -Identity
Should do the trick

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

MikeAWood
  • 2,566
  • 1
  • 13
  • 13
  • 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 '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 08 '11 at 01: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 08 '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 09 '11 at 21:51
  • Yeah, that's the issue. If I try to submit one, and there already exists a manual move, it errors. If I use Get-MoveRequest, and there isn't one, it errors. – Chris Nov 09 '11 at 22:00
  • 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. http://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 09 '11 at 22:09