Suppose I have a Windows service in a productive environment that does some kind of work. It’s secured and everything, and I have a very limited way of interact with it to maybe adjust its configuration or perform a maintenance work on it.
I thought it would be awesome if I could use Powershell to tap into that services and be able to check for internal objects and maybe change some configuration on the fly.
The idea would be to host a Powershell inside the service, easy job, create a runspace and a pipeline in which specific objects are exposed in the form of variables, no problem, and then be able to run Powershell code in that pipeline.
Easy done if the service had a GUI or if it was interactive in some way so it would just ask for an input, and I could push that input into the pipeline and maybe display the info from the returned PSObject. But, no GUI at all and neither I would like for it to have it. I made a proof of concept using a REST kind of interface to pass along the powershell code and execute it in the pipeline, and the look of it was really promising.
Now, since Powershell is built thinking of remoting, I was wondering if there could be some way of creating a remote session to invoke commands but not on the Powershell environment of the computer, but in the pipeline of the Powershell hosted inside my windows service.
There are tons of examples of Powershell self hosting applications but none takes remoting into consideration, from the server perspective. I’m not sure what was the intention in being able to host a powershell engine on a .NET application, but I think it would only be natural if I could initiate a remote connection to that engine, don’t you?
I don’t know if I’m terribly misguided. If that would be the case, what would be in your opinion the best way to use Powershell to interact with a windows service? Something like the way we use powershell to interact and configure Exchange for example.
I hope you’ll ask a question, too! Visit here for info.