# Powershell Remoting / Exchange 2010

I was tasked with updating our user creation / tear down tool to set an out of office message for users when their account is disabled following their termination.

Initially, I thought this would be as simple as adding a function to run Set-MailboxConfigurationAutoReply but every time the app tried to set a new out of office message I received the error: ‘Operation is not valid due to the current state of the object.’

Some google-fu led me to the fact that the way the Exchange commands were being loaded in the app is not supported in Exchange 2010. This method bypasses RBAC and in general, many commands just fail to work when a remote connection is established by force loading the snap-in and dot-sourcing the Remote Exchange script in a standard PoSH session:

With that being said, I’m surprised the Exchange commands in the app have functioned up until this point without using remoting.

I replaced the above code with the following:

Now, everything works as it should including the Set-MailboxConfigurationAutoReply command.