Quantcast
Channel: Hey, Scripting Guy! Blog
Viewing all articles
Browse latest Browse all 3333

PowerTip: Launch Console Command Embedded in Powershell Variable

$
0
0

Summary: Use a variable to launch a Windows PowerShell cmdlet and maintain the value of $LastExitCode.

Hey, Scripting Guy! Question How can I use Windows PowerShell to launch a variable that contains the path to a console application
           while retaining the error code?

Hey, Scripting Guy! Answer Use the & character before the content in question. This example launches Tree.com in System32 
           by passing in the Environment variable for Windows:

& "$ENV:Windir\system32\tree.com"

  


Viewing all articles
Browse latest Browse all 3333

Trending Articles