Reputation: 13535
I have some Windbg script where I can call out to a cmd shell via the .shell command. Now I want to execute some Windbg command and pipe the output to the shell script which should start powershell.exe to process the input data. So far I did fail.
In principle it should be possible to pass data from stdin to powershell pipes?
echo C: | powershell.exe -Command "| dir"
I do not want to create an extra powershell script because that would complicate the windbg script further and create external dependencies.
Upvotes: 4
Views: 2951
Reputation: 2835
You can use the predefined $input
variable to use the text you echo into powershell. In conjunction with the pipeline, this works perfectly:
echo C:\ | powershell.exe -command "$input | dir"
Edit: You also need to use echo C:\
. I'm not sure of the reasoning, but simply writing Get-ChildItem 'C:'
defaults to the current directory.
Upvotes: 8