I'd like to write a program that effectively "pipes" Powershell, so that I can send commands and parse the responses in C++, without actually opening the prompt on the screen.
Any tips?
Visual Studio Code with the PowerShell extension is the recommended editor for writing PowerShell scripts. It supports the following PowerShell versions: PowerShell 7.0 and higher (Windows, macOS, and Linux)
The Windows PowerShell prompt opens by default at the root of your user folder. Change to the root of C:\ by entering cd c:\ inside the Windows PowerShell prompt.
You can certainly do this but you'll need to use managed code as PowerShell's architecture is based entirely on the CLR object model.
I'm not sure of the C++ syntax but you can start with the PowerShell class in System.Management.Automation.dll and use its static Create method to create an instance to which you can pipe data and run commands.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With