Monday, January 19, 2009

run a cmdlet command from a cmd command

[] to run PowerShell commands from a cmd command prompt

step 1) press WinLogo-key 'R' and type cmd.exe

R:\> powershell.exe -command "get-service"

[] to run PowerShell commands from a Start | Run prompt

step 1) press WinLogo-key 'R' and type

PS> powershell -command "C:\Lindows\co\Administrator\wpsEventsClear.ps1"

[] to call PowerShell from a cmd command prompt that will sort the services

step 1) press WinLogo-key 'R' and type

R:\> powershell.exe -command "get-service | sort Name"

the entire command string is enclosed in quotation marks to prevent cmd from attempting to handle the pipeline.

No comments:

Post a Comment