How is a C # space / pipeline executed using a powershell script?

There are so many questions and answers about how to execute the powershell script command from C # code, but I would like to know how exactly the execution of the space / pipeline of the .px file is performed.

The context in which I ask is this: I created an asp.net base interface for a powershell script that installs a new website. He creates the site in IIS and configures the wwwroot folders, log folders, AD user and everything else that he needs. It works great when I run it as an administrator in powershell. However, when I run it through the C # pipeline, it breaks the channel into a parameter binding exception.

I am not answering this specific problem, I am just looking for an explanation of how the pipeline executes my file so that I can better understand what exactly is happening.

+6
source share
2 answers

Have you tried using ILSpy or opened a class in the Class> class to see the code for the class? I do this all the time to see how Microsoft implements a specific class. I would paste the code here if it was a short answer, but there are many for the System.Management.Automation.Runspaces or Microsoft.Powershell namespaces. See for yourself, and you can see exactly how Microsoft implements Powershell scripting.

Hope this helps.

+1
source

This is not a complete explanation of how the script works, but I wrote a blog post that describes the main bits.

Also a snapshot from one of the msdn pages on how powershell works :

The Powershell runtime is invoked as a workspace and, by default, process the commands synchronously and deliver the processing results to the host application so that they can be returned to the user.

+1
source

Source: https://habr.com/ru/post/950780/


All Articles