A variable that cannot be referenced in restricted language

This topic contains 1 reply, has 2 voices, and was last updated by  Don Jones 2 years, 5 months ago.

  • Author
  • #25251


    I am just wondering what the below error is. I am trying to run my script from PS 4.0. Actully its completely developed in PS 2.0. In 2.0 all is good. Please suggest what should I do to avoid this?

    Actually I am running my script on PS 4.0 which is connected to Exchange 2010 remotely. The below is the code I am using to establish the connection.

    $Cred=Get-Credential "LAB\Administrator"
    $s = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://dagn2.lab.com/PowerShell/ -Authentication Kerberos -credential $cred
    Import-PSSession $s

    I tried to google it, I found that it is something related to creating local profile for exchange server. I am not sure where to change it. Please help me to fix this.

    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          : InvalidOperation: (:) [], RuntimeException
        + FullyQualifiedErrorId : VariableReferenceNotSupportedInDataSection
        + PSComputerName        : dagn2.lab.com
  • #25261

    Don Jones

    You are connecting to a Remoting endpoint that is in Restricted mode, which does not allow variables – amongst many other things. This is common in Exchange, and is configured server-side.

You must be logged in to reply to this topic.