4

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.

1 Answer 1

8

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks. $input was the missing piece!
Re c: vs. c:\ : a mere drive spec. always refers to the current directory on that drive.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.