Powershell: Direct output to a variable.

Thursday, July 25th, 2013

I was asked if there was a way to capture output of a specific program to a variable.

Basically, the person wanted to get a version number from the program.

Played around and had a way to accomplish this  but I found a simpler approach.

$scriptOutput = & "c:\path\program.exe" -V 2&1

Obviously, the -V works with the program in question.

I am liking powershell

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: