A variable that cannot be referenced in restricted language

Welcome Forums General PowerShell Q&A A variable that cannot be referenced in restricted language

This topic contains 1 reply, has 2 voices, and was last updated by

 
Keymaster
3 years, 7 months ago.

  • Author
    Posts
  • #25251

    Inactive
    Points: 0
    Rank: Member

    Hi,
    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

    Keymaster
    Points: 1,673
    Helping HandTeam Member
    Rank: Community Hero

    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.

The topic ‘A variable that cannot be referenced in restricted language’ is closed to new replies.