I have an object that contains a field named PKBlock which accepts a script value
$o.PKBlock = { return $_.UserId }
or
$o.PKBlock = { return $_.GroupId + $_.ResourceId }
I would like to pass an object (shown here in json)
{
"UserId":"aodpkjpw92kjd",
"GroupId":"90djd0223djd",
"ResourceId":"012ekkkk023"
}
How do I execute the script block and get the return value?
I have tried the following (where $record is the object as an object):
Invoke-Command -ScriptBlock $o.PKBlock -InputObject $record
Invoke-Command -ScriptBlock $o.PKBlock -ArgumentList $record
$record | Invoke-Command -ScriptBlock $o.PKBLock