Quick and Easy Remote ExchangePowerShell


  1. Configure the powershell virtual directory with basic auth
    1. image
    2. image
  2. Forward 443 through your firewall (or publish with ISA)
  3. Copy this script, change the FQDN to match your server and save as RemoteExchange.ps1
      $usercredential = get-credential
      $pso = new-pssessionoption -skipcacheck -SkipCNCheck -SkipRevocationCheck
      $session= New-PSSession -configuration Microsoft.EXchange -ConnectionUri
      https://FQDN/powershell -credential $usercredential -authentication basic -sessionoption $pso
      import-pssession $session
  4. open powershell and run the script ./RemoteExchange.ps1
  5. Disconnect with “Remove-PSSession $Session”

Note: this script ignores Certificate checks, only use if you can trust the server you are connecting to!

You may need to set the Powershell Execution Policy so you can run the scripts

Set-ExecutionPolicy Unrestricted or Set-ExecutionPolicy RemoteSigned

*Note: you do have to enable remote powershell access for the user

2 thoughts on “Quick and Easy Remote ExchangePowerShell

  1. [PS] C:\inetpub\wwwroot\PowerShell>./RemoteExchange.ps1

    cmdlet get-credential at command pipeline position 1
    Supply values for the following parameters:
    Credential
    The term ‘new-pssessionoption’ is not recognized as a cmdlet, function, operabl
    e program, or script file. Verify the term and try again.
    At C:\inetpub\wwwroot\PowerShell\RemoteExchange.ps1:2 char:27
    + $pso = new-pssessionoption <<<< -skipcacheck -SkipCNCheck -SkipRevocationChe
    ck
    The term 'New-PSSession' is not recognized as a cmdlet, function, operable prog
    ram, or script file. Verify the term and try again.
    At C:\inetpub\wwwroot\PowerShell\RemoteExchange.ps1:3 char:24
    + $session= New-PSSession <<<< -configuration Microsoft.EXchange -ConnectionUr
    i https://adatum.com/powershell -credential $usercredential -authentication bas
    ic -sessionoption $pso
    The term 'import-pssession' is not recognized as a cmdlet, function, operable p
    rogram, or script file. Verify the term and try again.
    At C:\inetpub\wwwroot\PowerShell\RemoteExchange.ps1:4 char:17
    + import-pssession <<<< $session

    • What version of powershell are you using?
      I should have prefaced that this only works on powershell version 2 against an exchange 2010.
      You will get that if you are running version 1 of powershell and not version 2.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s