Pages

Search This Blog

Wednesday, May 23, 2012

Connecting to Exchange 2010 using remote PowerShell

Exchange 2010 added a new way of servers management by utilizing remote capabilities for Windows PowerShell 2.

The Exchange Management Shell is the administrative interface that enables you to manage your Microsoft Exchange Server 2010 organization from the command line. If you don't either have the Exchange management tools installed or that your client OS is 32 bit edition and you still want to connect to, and administer, a server running Exchange 2010, In this post I’ll explains how you can create a manual remote Shell to connect to an Exchange 2010 serve

First of all let’s justify the prerequisites :

  • Install Windows Management Framework  [ Not required for Windows  7 / Server 2008 R2 ] :

Windows Management Framework contains Windows PowerShell and WinRM. For more information, see Install Windows Management Framework

  • Join your computer to a Windows domain

If you want to use your current network credentials, the domain you're joined to must be trusted by the domain where the Exchange server resides. Your domain doesn't need to be trusted if you manually specify credentials that are valid in the remote domain.

  • Open TCP port 80  :

TCP port 80 must be open between your computer and the remote Exchange 2010 server, and the port must be allowed through Windows Firewall on the Exchange 2010 server.

  • Enable user to use remote PowerShell :

Remote PowerShell is enabled for user account used for Exchange servers installation , if yours are not you can enable it by executing Set-User username -RemotePowerShellEnabled $True.

Now let’s get our hands dirty :

  • First , save credentials as a variable :

 $ITGD=Get-Credential

image

  • Then, create a remote PowerShell session :

$ITGDSession=New-PSSession –ConfigurationName Microsoft.Exchange –ConnectionUri http://ServerName/powershell –Credential $ITGD

image

  • Finally , import the previously created session :

Import-PSSesion $ITGDSession

image

Now , remote session is imported and we can start using all Exchange CMDlets :

image

Here is an example with Get-Mailbox CMDlet :

image

To end the remote session , all you need is to execute Remove-PSSesion $ITGDSession .

Finally , if you got the below error while importing the session which is due to that execution policy for PowerShell is set to Restricted by default .

image

You can execute Set-ExecutionPolicy Unrestricted and re-import session again and all will go fine

image

Enjoy managing your Exchange servers remotely Open-mouthed smile

No comments:

Post a Comment