I'm having difficulty running Exchange 2010 cmdlets through remote PowerShell sessions.
I start my local PowerShell session as Administrator and issue the following commands --
PS C:\Windows\system32> $mailcred = Get-Credential
PS C:\Windows\system32> $mailSession = New-PSSession -ComputerName MAILSRV -Credential $mailcred
PS C:\Windows\system32> Enter-PSSession $mailSession
[MAILSRV]: PS C:\Users\jdoe\Documents> Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010
[MAILSRV]: PS C:\Users\jdoe\Documents> hostname
MAILSRV
[MAILSRV]: PS C:\Users\jdoe\Documents> Get-ExchangeServer
Value cannot be null.
Parameter name: serverSettings
+ CategoryInfo :
+ FullyQualifiedErrorId : System.ArgumentNullException,Microsoft.Exchange.Management.SystemConfigurationTasks.GetExchangeServer
[MAILSRV]: PS C:\Users\jdoe\Documents> get-mailbox
Value cannot be null.
Parameter name: serverSettings
+ CategoryInfo :
+ FullyQualifiedErrorId : System.ArgumentNullException,Microsoft.Exchange.Management.RecipientTasks.GetMailbox
As you can see, none of the Exchange cmdlets are working. What could be the issue?
ImportSystemModules
which loads registered modules in to the current runspace. Exchange cmdlets may not be automatically imported into the remote session/runspace.