Sysadminsblog.com Anything for sysadmins!

5Jul/100

Exchange 2010 Remote Powershell

One of the new features of Exchange 2010 is the ability to setup a remote connection to an Exchange 2010 organization without having to install the management tools. However you do have to install the Windows Management Framework Core unless you're on Windows 7 or Windows 2008 R2 where it comes preinstalled. Click here to go to the download page for Windows Management Framework Core.

Requirements

  • Windows Vista SP1 and higher or Windows 2008 SP1 and higher
  • Windows Management Framework Core which includes:
    • Windows Powershell 2.0
    • WinRM 2.0
  • Permissions to make remote Powershell sessions
  • Exchange 2007 Powershell snapin must be unloaded

To grant remote Powershell session permissions you have to run the following command:

    Set-User -Identity <username> -RemotePowershellEnable $True

To unload the Exchange 2007 Powershell snapin run the following command:

    Remove-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin

Establishing the connection

Let's make a remote connection to our Exchange 2010 organization!

  1. Store the credential in a variable:
    $User = Get-Credential

  2. Store a Powershell session in a variable:
    $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "http://<servername>/powershell" -Credential $User
  3. Import the server-side Powershell session to the client side one:
    Import-PSSession $Session

    During this step you'll see a progress bar while the Exchange cmdlets are being imported

You now have a working remote Powershell session with your Exchange 2010 organization!

Closing the connection

When you're done with the session you'll have to remove it. To do so, you can run the following command:

    Remove-PSSession $Session

As you can see, the session has been closed. Don't forget to either exit your local Powershell session or remove the $User variable, as this still has the account stored. If you want to remove the variable, use the following command:

    Remove-Variable User