masber
masber

Reputation: 3067

How can I connect to Exchange server remotely through Powershell and a PSSessionConfiguration

I am trying to connect to exchange remotely and run queries from Powershell.

This is my configuration file on the Exchange server:

Register-PSSessionConfiguration -Name "Exchange" -StartupScript "C:\ProgramFiles\Microsoft\Exchange Server\V14\Bin\RemoteExchange.ps1"

This is how I am connecting from my local computer:

$s = New-PSSession -ComputerName cmsexch -ConfigurationName "Exchange" -Authentication Kerberos -credential $cred

And this is the error message I am getting:

New-PSSession : Running startup script threw an error: Cannot find path 'HKLM:\Software\microsoft\ExchangeServer\v14\CentralAdmin' because it does not exist..

NOTE:

QUESTIONS:

Thank you very much

Upvotes: 2

Views: 1520

Answers (1)

Ryan Doles
Ryan Doles

Reputation: 31

The connection string from your local computer appears to be missing a few things. I believe that the following code is what you're looking for. You would need to fill in your FQDN and that's about it. These 3 lines get me right in. The 32/64 bit should make no difference.

$UserCredential = Get-Credential

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://<FQDN of your Exchange server>/PowerShell/ -Authentication Kerberos -Credential $UserCredential

Import-PSSession $Session

This TechNet Exchange Knowledge Article might elaborate or at least point you in the right direction. http://technet.microsoft.com/en-us/library/dd335083%28v=exchg.150%29.aspx

Upvotes: 1

Related Questions