Monday, 12 October 2015

Exchange 2013, 2016 Remote PowerShell

Often when scripting, you may need to pull data from Exchange but it's not always practical to install the Exchange Management Tools in order to run the Exchange Management Shell. 

Luckily, there's a way around this. You can create a new remote session to the Exchange server, specify the configuration name and then import the session. 

In this example, we'll connect to our Exchange server, and output a list of mailboxes - all of this will be run from another server which doesn't have any Exchange tools or PowerShell cmdlets, snap-ins or modules.

$server = ""
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://$server/PowerShell/ -Authentication Kerberos
Import-PSSession $Session

Once the session is established, we can run any of the Exchange cmdlets. Here is the Get-Mailbox cmdlet run from that same remote session:

No comments:

Post a comment