How to pass a local PS5 class to a remote session?

So pass to a local function you could do something like…

function FTest
Write-Output $Myoutput

$FTestDef = “function FTest { ${function:FTest} }”

Invoke-Command -ArgumentList $FTestDef -ComputerName labserver01 -ScriptBlock {
Param( $FTestDef )

. ([ScriptBlock]::Create($FTestDef))

Write-Host "You can call the function as often as you like:"
FTest "It works!"


or something like

Invoke-Command -ScriptBlock ${function:foo} -argumentlist “Yay” -ComputerName labserver01

But how would you pass a PS5 class?

I’m not sure you can, in the current version (keep in mind classes are far from “done” at this point), apart from just statically passing it.

Thanks for the heads up Don.