is there any comlet like expand-string?
$a="ab cd"
$command = 'dir $a'
Write-Host (expand-string $command)
expected:
dir abcd
Note, I know I can just use $command="dir $a" to expand the string, but that was not I want to, I need to save the string dir $a as a literal in a variable and expand it later in a command.
Invoke-Commandwould work - it RUNS the string instead of simply expanding it.$ExecutionContext.InvokeCommand.ExpandString($Command)