I would like to do some "self-referencing"(?) in PowerShell v3.
In a remote script I do:
New-Object PSCustomObject -Property @{MyProperty="test"}
But I don't know how to access this Property inside this remote script. This Property exist because in my local script I'm able to access it by
$MyScriptBlock.MyProperty
Inside my $MyScriptBlock
-
In C# I could write
this.MyProperty="MyInfo"
In VB I could write
Me.MyProperty="MyInfo"
In HTA I could write
document.MyProperty="MyInfo"
In some other
self.MyProperty="MyInfo"
So, how to do in PowerShell v3 ?
How to do Self-referencing in PowerShell ? (not only for this script)
Today, I can't pipe it (script a bit complex with 700 lines) I have to reuse this variable.
To explain what this script do :
I have a remote script on a server, called with
$MyRemoteScript = Invoke-Command -Session $session -ScriptBlock $MyRemoteScriptBlock
Inside the remote script I do
New-Object PSCustomObject -Property @{MyProperty= $False}
In remote script, sometime, I would like to change MyProperty
Later, in host script, I read MyProperty by
$Success = $MyRemoteScript.MyProperty