The first step in a do-it-yourself EMS session is to start PowerShell and use the Get-Credential cmdlet to input the username and password that we need to connect to the target Exchange organization. These credentials should be for a privileged account as otherwise you won’t be able to do very much.

$Credentials = Get-Credential

PowerShell displays a dialog to allow you to put in the username and password that we will use to connect. We then create a new remote PowerShell session and connect to the remote Exchange organization. Note that Kerberos is specified as the authentication method.

$ExSession = New-PSSession –ConfigurationName Microsoft.Exchange –ConnectionUri ‘http://exc2010.ct11.com/PowerShell/?SerializationLevel=Full’ -Credential $Credentials –Authentication Kerberos

 

After we establish a session, we can import the set of Exchange cmdlets that our account is allowed to access. As shown in the screen shot below, EMS responds with an acknowledgement that it has imported the specified command set into the session.

Import-PSSession $ExSession

After the cmdlets are loaded into your session, you can work remotely in exactly the same manner as if you were logged onto the server. The Get-Command cmdlet will list the cmdlets loaded into the session and the Get-Help cmdlet can be run to show the help that is available for any of the cmdlets that are loaded into the session. Unfortunately, even though the EMS startup screen indicates that you can use wildcards with the Get-Help cmdlet, due to some issues with the operating system, the advent of Remote PowerShell has removed this ability that exists in Exchange 2007.

Once your session is established and you’re connected to Exchange 2010, all transactions flow across HTTP via IIS to be executed on the target server. When you are finished, you can terminate the session with the Remove-PSSession cmdlet.

Remove-PSSession $ExSession

 

Referencehttp://thoughtsofanidlemind.wordpress.com/2010/09/29/connecting-to-exchange-2010-with-powershell/

 

arrow
arrow
    全站熱搜

    masterman 發表在 痞客邦 留言(0) 人氣()