Whenever i run my script on my window 8.1 using PowerShell (Run with Administrator), it will prompt me the error as below when it run till certain script.
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 : pod51053psh.outlook.com
Error happened when I try to Set-Mailbox to update the CustomAttribute.
$User = "admin@xxx.edu.my"$Pass = get-content C:\xxx.txt | ConvertTo-SecureString
$Livecred = New-Object -typename System.Management.Automation.PSCredential -ArgumentList $User, $Pass
$pso = New-Pssessionoption -OperationTimeout 43200000
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://pod51053psh.outlook.com/powershell-liveid?PSVersion=2.0/ -Credential $LiveCred -Authentication 'Kerberos' -AllowRedirection -sessionOption $pso
Import-PSSession $Session -AllowClobber | Out-Null
Connect-MsolService -credential $Livecred
Import-module msonline