I want to run some executable on Windows using PowerShell. Path to this executable should be resolved with environment variable.
For example
running command
C:\Windows\system32\cmd.exe
as
$Env:SystemRoot\system32\cmd.exe
I have tried this option and it raises following exception
At line:1 char:16
+ $Env:SystemRoot\system32\cmd.exe
+ ~~~~~~~~~~~~~~~~~
Unexpected token '\system32\cmd.exe' in expression or statement.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : UnexpectedToken
What is the right way to do it?