Storing Cmd-Results in PowerShell Variables

You can run classic cmd commands from within PowerShell and store the results in variables. All you need to do is invoke cmd.exe with the /c switch like so:

$result = cmd.exe /c dir
$result

Twitter This Tip! ReTweet this Tip!


Posted Aug 17 2009, 08:00 AM by ps1
Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.