Using Remote PowerShell to Provision Exchange 2010 Users

Provisioning Exchange 2010 Users with Remote Powershell in Windows XP/2003

Exchange 2010 provides us with some new PowerShell features in order to run commands remotely to a CAS server. However, there are a few prerequisites you need to know in order to do this. First of all, Windows 2003 or XP, out of the box, does not provide this feature. You'll have to download the "WINRM" update patch that installs Windows PowerShell. Here is the URL for the download:

Also, you need to enable remote PowerShell on your Exchange 2010 CAS server with the following PS command:

'Enable-PSRemoting'Binary Tree Tech Tip

Then choose "YES" to configure Firewall ports if necessary and then ensure that the 'WINRM' service is running on the CAS Server. There is a command to verify that you have the necessary authority to run the commands. The command is:

'get-user (username) | fl'

Then, verify that 'RemotePowerShellEnabled' is set to 'True'. To set this, enter:

‘Set-User –identity (username) –RemotePowerShellEnabled $true’

Finally, after ensuring that the Exchange server is accepting remote PS commands, you'll need to start the Windows Remote Management Service task from Services.MSC console on the Windows 2003/XP machine and then run Windows PowerShell Command from Program\Accessories:

'set-executionpolicy remotesigned'

Both the CAS Server and Windows 2003/XP machines are now configured to establish Remote Powershell sessions. In order to initiate a Remote Powershell session with the CAS Server, you need to use the Enter-PSSession cmdlet. Open a PowerShell command prompt from the Windows 2003/XP machine and enter the following:

'Enter-PSSession -ConnectionURI (http://CAS Server Hostname/powershell) -ConfigurationName Microsoft.Exchange'

Now when you type commands in the Powershell window they are executed remotely on the CAS Server. You can run any user provisioning cmdlets such as 'New-Mailbox' or 'Enable-Mailbox' from the Windows 2003/XP machine just as if you were using the CAS Server's console. 

To end the Remote Powershell session, type 'Exit-PSSession', or simply close the Powershell window.

That's it! Have fun, but be careful, this is pretty powerful.

- Rob