Remote PowerShell to manage Exchange, even without the Exchange Management Shell installed

Following on from yesterday’s Exchange Admin Center/Outlook Web App tips, I thought I’d share another gem that came from Microsoft Exchange Premier Field Engineer and PowerShell author Mike Pieffer (@mike_pfeiffer) in the Microsoft Virtual Academy Core Solutions of Microsoft Exchange Server 2013 Jump Start course.

Sometimes, you’ll need to perform an operation on an Exchange Server and you won’t have the Exchange Management Shell installed.  You may be able to carry out the operation graphically using the Exchange Admin Center but, more likely, you’ll need to invoke a remote PowerShell session.

The magic commands (which need PowerShell v2 or later) use implicit remoting via the IIS PowerShell virtual directory (proxied via an Exchange server with the CAS role installed):

$session = New-PSSession -ConfigurationName microsoft.exchange -ConnectionUri http://servername/powershell
Import-PSSession $session

After running these commands, you should be able to run Microsoft Exchange cmdlets, as long as you have the appropriate permissions assigned via Exchange’s Role Based Access Control mechanism. I’ve used the same approach previously to connect to Exchange Online (Office 365) using remote PowerShell.

A couple of additional points to note: because you’re running a remote PowerShell session, you’ll also need the script execution policy to allow RemoteSigned scripts; also, don’t forget to tear down the session when you’re done, using Remove-PSSession $session.

4 Comments

  • Thursday 28 November 2013 - 16:53 | Permalink


    I didn’t know this was possible!
    It’s probably a basic step when learning PowerShell but when you teach yourself as you go along it’s easy to miss features like this.

    Thanks for sharing

  • Monday 2 December 2013 - 17:55 | Permalink


    Glad it was useful Thom!

  • Wednesday 11 December 2013 - 9:05 | Permalink


    Hi Mark, A small typo in there, “implicit removing” should be “implicit remoting”, which is the concept that makes remote access to these and other cmdlets possible if people want to read more.

    Regards,
    Alastair.

  • Wednesday 11 December 2013 - 17:20 | Permalink


    Oops – thanks Alastair – typo corrected now. Although “implicit removing” could be another interesting concept ;-)

  • Leave a Reply

    %d bloggers like this: