Q. How can I launch a Windows PowerShell instance to run a command from a cmd.exe prompt?

John Savill

March 26, 2009

1 Min Read
ITPro Today logo

A. To start a PowerShell session, you just need to run the "start powershell" command. However, you can also pass a command through the -Command switch. If you don't want the PowerShell instance to close once the command has run, you can also pass the -NoExit switch. For example, you may want to start a number of PowerShell instances to monitor counters on two different servers. The commands below fire up four PowerShell environments, each monitoring different counters on different servers. Run the following four commands from a cmd.exe instance.

start powershell -NoExit -Command "&{ Get-Counter '\savdalvs01Cluster Shared Volumes(ClusterStorageVolume1)IO Writes' -Continuous }"start powershell -NoExit -Command "&{ Get-Counter '\savdalvs01Cluster Shared Volumes(ClusterStorageVolume1)Redirected IO Writes' -Continuous }"start powershell -NoExit -Command "&{ Get-Counter '\savdalvs02Cluster Shared Volumes(ClusterStorageVolume1)IO Writes' -Continuous }"start powershell -NoExit -Command "&{ Get-Counter'\savdalvs02Cluster Shared Volumes(ClusterStorageVolume1)Redirected IO Writes' -Continuous }"

Related Reading:

Check out hundreds more useful Q&As like this in John Savill's FAQ for Windows. Also, watch instructional videos made by John at ITTV.net.

About the Author(s)

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like