I’m trying to put together a powershell script that we can use for some custom scripts to a commercial IT monitoring solution (StableNet by Infosim.de). The product has a neat feature on passing on parameter to scripts in a secure manner, and avoid the parameters being visible in a system tools like ps/Task Manager. Rather than having them as parameters on the command line, the solution can call the script with a “–inline” parameter, which expects the called script to then read all other parameters via inline parameter setting. When inline parameters are used, the running script should be able to start and wait for the calling code to supply the parameters separated by CR/LF.
I’ve done some code using C# which simply uses:
string host = Console.ReadLine(); string user = Console.ReadLine(); string pass = Console.ReadLine(); string filePath = Console.ReadLine();
This works fine in C#. But I would also like to make some powershell script for quicker development. However, as StableNet starts all powershell scripts with -noninteractive parameter I can’t use Read-Host calls to ask for the inline parameters.
So the question is if anyone has any good ideas how I can achieve these inline parameter settings with a Powershell script and still make it work as a -noninteractive script?
I’ve tried a few options based on the [System.Console]::OpenStandardInput().Read()
, but I’ve yet to be successful.
ThomasN is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.