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?
You're trying to connect to the default remoting endpoint on the Exchange Server and add the ps snapins from there. This is wrong. Replace your first 3 lines with this:
You don't have to enter the session, import it into the local session instead. From here on, you can use the Exchange-specific CmdLets locally. Also, some of the Exchange .Net types are installed with the Exchange Management Console, so this needs to be installed on your local computer if you want to do stuff with mailbox sizes (Exchange uses it's own types for size objects)
You can do it like this, with import-pssesion and specifing the connectionURI & ConfigurationName.
This requires that you do allow tcp port 80 in your firewall.
Using that session, you can also enter it like you wanted:
I had the same problem once. I think the solution was this:
then add your snap-in, and run your commands
source: http://forums.veeam.com/viewtopic.php?f=2&t=7514
Did you try installing the Exchange Management Tools from the DVD and configure your workstation ?
I would suggest using remoting endpoint that is part of normal exchange installation. You can find more details here
I've used it successfully both with EX 2010 and EX 2013. It's supported way and it follows RBAC rules, so I would suggest using it rather than adding Exchange snappin to "normal" remoting endpoint.
The problem is that both machines should be in the same domain.
Also make sure you use the domain account, not the local one.