Run a test-mailflow within the invoke-command?

rated by 0 users
Not Answered This post has 0 verified answers | 1 Reply | 2 Followers

Top 50 Contributor
78 Posts
jwhite posted on 07-31-2012 6:44 PM

I'm trying to run the test-mailflow cmdlet, within the invoke-command cmdlet.  I'm on a Client Access Server and I can issue the test-mapiconnectivity cmdlet against a user.  However in order to run the test-mailflow cmdlet, I need to be on the mailbox server that the user is on.

I'm referencing this article:

The problem is I keep getting the error:

A variable that cannot be referenced in restricted language mode or a Data section is being referenced. Variables that
can be referenced include the following: $PSCulture, $PSUICulture, $true, $false, and  $null.
    + CategoryInfo          : ParserError: (data:Token) [], ParseException
    + FullyQualifiedErrorId : VariableReferenceNotSupportedInDataSection

Anyone know what I'm missing or how I can get the invoke-command to run the mailflow test remotely?


All Replies

Top 10 Contributor
640 Posts

Welcome to tricky.

So, Remoting - which is what Invoke-Command uses - can connect to one of many different endpoints ("session configurations") on a remote server. The one you're connecting to is configured with restrictions, including - based on the error message - turning off the PowerShell scripting language. So whatever you've remoted into doesn't support variables.

You've got some choices.

First, connect to a different endpoint. Run Get-PSSessionConfiguration on the server to see what it's got. If it has a default "Microsoft.PowerShell" endpoint, connect to that - use the -ConfigurationName parameter of Invoke-Command.

Second, don't use a variable. Try using (nested) commands in parentheses instead, if you can construct your command that way. Happy to help if you want to show me what you're up to.

Page 1 of 1 (2 items) | RSS
Copyright 2012 All rights reserved.