Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
A pipeline-heavy twist on a unique PowerShell coding style seen by a threat actor. This is probably as close to OOP PowerShell as you could get in the PSv2 days.
$MyObject = "" |Select-Object _prop1,_prop2
$MyObject |Add-Member -Name Prop1 -MemberType ScriptProperty -Value {return $this._prop1} -SecondValue {param([int]$value) $this._prop1 = $value}
$MyObject |Add-Member -Name Prop2 -MemberType ScriptProperty -Value {return $this._prop2} -SecondValue {param([int]$value) $this._prop2 = $value}
$MyObject |Add-Member -Name SumProperties -MemberType ScriptMethod -Value { return $this.Prop1 + $this.Prop2 }
$MyObject.Prop1 = 3
$MyObject.Prop2 = 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.