Tuesday, April 12, 2011

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

Using Remote PowerShell to provisionin Exchange 2010 Users

Exchange 2010 provides us with some new features for PowerShell 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, the Windows 2003 or XP, out of the box does not provide this. You will have to download the "WINRM" update patch that installs Windows PowerShell. Here is the URL for the download:

http://www.microsoft.com/downloads/en/details.aspx?FamilyID=F002462B-C8F2-417A-92A3-287F5F81407E


Also, you need to enable remote PowerShell on your Exchange 2010 CAS server with the following PS command, 'Enable-PSRemoting' . You can 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 the user you are logged in with has the necessary authority to run the commands and it is, 'get-user (username) | fl'.

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, there are a few more settings on the Windows 2003/XP machine prior to running.

Start the Windows Remote Management Service task from Services.MSC console

Then run Windows Powershell Command from Program\Accessories:

set-executionpolicy remotesigned

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

3 comments:

Amit Dangwal said...

Good one.. Thanks for sharing this.
www.inovate.info

TXGEEKGIRL said...

I was able to follow your directions and get a connection between servers. When I run my code line for line on the Exch2010 Box in PS for Exchange, it runs perfect. When I remote connect, I get errors like the cmdlet cannot be found or the parameter cannot be found. This leads me to believe that the connection I think I have is not correct.

Enter-PSSession -ConnectionURI http://exch2010.domain.com/powershell -ConfigurationName Microsoft.Exchange
gets me a prompt on my server:

[exch2010.domain.com]: PS >

From there I should be able to run these two lines if I indeed have a connection to PS for Exchange:

Enable-Mailbox -identity 'Fred Flintstone'
Set-Mailbox -Identity 'Fred Flintstone' -ApplyMandatoryProperties"


How can I be absolutely positive I am connected to the Powershell for Exchange to run my code?

Unknown said...

This could be a DNS issue, try testing a ping or nslookup to your exch2010.domain.com and validate where it ends up. This should match the IP Address for your Exchange Server.