Quantcast
Channel: Exchange Server 2013 - General Discussion forum
Viewing all articles
Browse latest Browse all 4521

Exchange Remote Powershell and variables

$
0
0

Hi

I use the following code in one of my scripts:

    $sb = {param ($MailAlias) (Get-MailboxStatistics -Identity $($MailAlias)).TotalItemSize.value.ToBytes()}
    [int]$MailboxSize = Invoke-Command -Session $session -ScriptBlock $sb -ArgumentList $Mailbox.Alias

But after moving to Exchange 2013, I get an error that I can't use the variable, as I am in restricted mode.

On my 2010 Exchange, I change a setting in IIS after this post: http://blog.mimecast.com/2011/08/get-full-control-over-your-exchange-remote-powershell-session/

This I just can't seam to get to work, anyone know how to get into FullLanguageMode ?

The error looks as follows:

At line:1 char:1+ param ($MailAlias) (Get-MailboxStatistics -Identity $($MailAlias)).TotalItemSize ...+ ~~~~~~~~~~~~~~~~~~
A Begin statement block, Process statement block, or parameter statement is not allowed in a Data section.
At line:1 char:20+ param ($MailAlias) (Get-MailboxStatistics -Identity $($MailAlias)).TotalItemSize ...+                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Method calls are not allowed in restricted language mode or a Data section.
At line:1 char:20+ param ($MailAlias) (Get-MailboxStatistics -Identity $($MailAlias)).TotalItemSize ...+                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Property references are not allowed in restricted language mode or a Data section.
At line:1 char:20+ param ($MailAlias) (Get-MailboxStatistics -Identity $($MailAlias)).TotalItemSize ...+                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Property references are not allowed in restricted language mode or a Data section.
At line:1 char:55+ param ($MailAlias) (Get-MailboxStatistics -Identity $($MailAlias)).TotalItemSize ...+                                                       ~~~~~~~~~~
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: (:) [], ParseException+ FullyQualifiedErrorId : InvalidScriptBlockInDataSection+ PSComputerName        : 4twexch1


Viewing all articles
Browse latest Browse all 4521

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>