Invoke-Command: Value cannot be null

by TomK2 at 2012-09-20 00:06:21

Hi Newsgroup,

I’m a newbie here.

I try to call an Exchange 2010 Powershell command with Invoke-Command, but I always get the following error message:

Value cannot be null.

Parameter name: serverSettings

+ CategoryInfo: NotSpecified (:slight_smile: [Get-MailboxDatabase], ArgumentNullException

+ FullyQualifiedErrorId : System.ArgumentNullException.Microsoft.Exchange.Management.SystemConfigurationTasks.GetMailboxDatabase

Get-MailboxDatabase normally needs no parameters. Other Exchange Powershell commands return the same error message.

The call of the command is the following:

invoke-command -computername ‘dummy-server’ -scriptblock { add-pssnapin ‘Microsoft.Exchange.Management.Powershell.E2010’; get-mailboxdatabase }

Thank you for any help.

Thomas
by RichardSiddaway at 2012-09-20 03:02:22
If you run the scriptblock on the remote server does it work?

also check the contents of exshell.psc1 and remote-exchange.ps1 to see if you need anything else
by TomK2 at 2012-09-20 03:45:57
Hi Richard,

thanks for your answer.

if I run the scriptblock with Invoke-Command on the Exchange Server, it gives the same error message.

If I call only Get-MailboxDatabase on the Exchange Server (without Invoke), it works (lists one test database).

Thomas
by TomK2 at 2012-09-20 04:23:39
Hi Richard,

in our exshell.psc1, the PSVersion is 1.0 (should this be 2.0 ?), the PSSnapin is "Microsoft.Exchange.Management.Powershell.E2010"

What are the important settings in remote-exchange.ps1 ? - this file seems to be ok.

Thomas
by mjolinor at 2012-10-09 08:22:23
You need to connect to one of the Exchange management sessions, not a generic PS session.



$EX = new-pssession -configurationname Microsoft.Exchange -ConnectionURI http://<Exchange Server Name>/powershell/ -authentication kerberos

Invoke-Command -ScriptBlock {get-mailboxdatabase} -Session $EX