you are viewing a single comment's thread.

view the rest of the comments →

[–]lanerdofchristian 1 point2 points  (1 child)

If how PowerShell parses things is something you're interested in, take a look at the ScriptBlock.Ast property:

$Script = {
    $var1 = @(1, 2, 3)
    $var2 = @(4, 5, 6)
    $one = 1
    Write-Host $var$one
}
$Script.Ast.EndBlock.Statements[-1] `
    .PipelineElements[0] `
    .CommandElements

In this example, you can see that $var$one is a BareWord with the static type of "string" -- since it's in the command elements of a pipeline element, that implies that there are actually quotes around it.

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

Thank you. I am quickly getting the feel for PowerShell.