Remote Exchange Powershell – Value cannot be null. Parameter name: serverSettings

Problem

I have tried to get mailbox user details in Exchange 2010 from remote computer through powershell script. To run Exchange management powershell cmdlets in remote machine, I have created new remote powershell session using Enter-PSSession and added PSSnapin Microsoft.Exchange.Management.PowerShell.E2010. Things are working fine until loading exchange management pssnapin, but I am getting the error “Value cannot be null. Parameter name: serverSettings” when executing the Exchange management cmdlet Get-Mailbox.

Powershell script:

$cred = Get-Credential
Enter-PSSession -ComputerName ExchSVR -Credential $cred
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010
Get-Mailbox Morgan

Error:

PS C:> $cred = Get-Credential
PS C:> Enter-PSSession -ComputerName ExchSVR -Credential $cred
[ExchSVR]: PS C:UsersMorganDocuments> Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010
[ExchSVR]: PS C:UsersMorganDocuments> Get-Mailbox Morgan
Value cannot be null.
Parameter name: serverSettings
    + CategoryInfo          :
    + FullyQualifiedErrorId : System.ArgumentNullException,Microsoft.Exchange.Management.RecipientTasks.GetMailbox

Solution

I have concluded into following solution after I have analyzed some time. Use the following script to connect Exchange Management PowerShell when you are running Exchange management powershell commands from remote computer (i.e From other domain machine).

$cred = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://<FQDN of Exchange Server>/PowerShell/ -Credential $cred -Authentication Kerberos
Import-PSSession $Session 
Get-Mailbox Morgan
Advertisement

Leave a Comment