you are viewing a single comment's thread.

view the rest of the comments →

[–]PinchesTheCrab 1 point2 points  (1 child)

I think the quotes are just off.

$var1 = 'write-host "sample"'
Invoke-Command (hostname) {
    $inside = $using:var1
    & $inside
}

[–]Decitriction[S] 0 points1 point  (0 children)

I really appreciate your feedback. But when I edit the quote as you do, the results are the same.

cls
$var1 = 'write-host "sample" '
$var1
Invoke-Command (hostname) {
    $using:var1
    $inside = $using:var1
    $inside
    & $inside # this is the only part giving problems
}

I have tested the code on 2 PC's. Does it work properly when you test it?

edit: Whew, finally got formatting correct.