P pstein Extraordinary Member Joined Mar 20, 2010 Messages 454 Oct 30, 2019 Thread Author #1 I want to execute a PowerShell command from Command Prompt. This should be done by entering ONE command! I DO NOT want to start PowerShell first and then enter the PowerShell command. Instead I want to enter something like powershell.exe -command "......." How does that work in detail on Win7? Peter
I want to execute a PowerShell command from Command Prompt. This should be done by entering ONE command! I DO NOT want to start PowerShell first and then enter the PowerShell command. Instead I want to enter something like powershell.exe -command "......." How does that work in detail on Win7? Peter
Solution Neemobeer Oct 31, 2019 Looks like the -command {<command>} format doesn't redirect to stdout use -command "& {<command>}" instead
Looks like the -command {<command>} format doesn't redirect to stdout use -command "& {<command>}" instead
Neemobeer Cloud Security Engineer Staff member Joined Jul 4, 2015 Messages 8,998 Oct 30, 2019 #2 powershell.exe -command {command1;command2;command3} or powershell.exe -command "&{command1;command2;command3} " Examples PowerShell -Command {Get-EventLog -LogName security} PowerShell -Command "& {Get-EventLog -LogName security}" Upvote 0 Downvote
powershell.exe -command {command1;command2;command3} or powershell.exe -command "&{command1;command2;command3} " Examples PowerShell -Command {Get-EventLog -LogName security} PowerShell -Command "& {Get-EventLog -LogName security}"
P pstein Extraordinary Member Joined Mar 20, 2010 Messages 454 Oct 31, 2019 Thread Author #3 Why does Powershell -Command {Get-HotFix | Sort InstalledOn -Desc} NOT work? When I enter this in CmdPrompt then the output is: "Input file specified two times." Upvote 0 Downvote
Why does Powershell -Command {Get-HotFix | Sort InstalledOn -Desc} NOT work? When I enter this in CmdPrompt then the output is: "Input file specified two times."
Neemobeer Cloud Security Engineer Staff member Joined Jul 4, 2015 Messages 8,998 Oct 31, 2019 #4 Looks like the -command {<command>} format doesn't redirect to stdout use -command "& {<command>}" instead Upvote 0 Downvote Solution
Looks like the -command {<command>} format doesn't redirect to stdout use -command "& {<command>}" instead