Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does a C# runspace/pipeline execute a powershell script?

Tags:

c#

powershell

There are so many questions and answers about how to execute a powershell script from C# code, but I would like to know how exactly the runspace/pipeline performs the execution of the .ps1 file.

The context in which I am asking is this: I've built a basic asp.net front end for a powershell script that sets up a new website. It creates the site in IIS and sets up wwwroot folders, log folders, an AD user and everything else that it needs. It works perfectly when I run it as an admin in powershell. However, when I run it through my C# pipeline, it breaks the pipe with a parameter binding exception.

I'm not after an answer to this specific problem, I'm just looking for an explanation of how the pipeline executes my file so that I can have a better understanding of what exactly is going on.

like image 434
harrietgrace Avatar asked Aug 01 '13 04:08

harrietgrace


People also ask

How exactly does AC work?

As the liquid refrigerant inside the evaporator coil converts to gas, heat from the indoor air is absorbed into the refrigerant, thus cooling the air as it passes over the coil. The indoor unit's blower fan then pumps the chilled air back through the home's ductwork out into the various living areas.


1 Answers

It's not a complete explanation of how the runspace works, but I've written a blog post covering the main bits.

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

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

like image 154
harrietgrace Avatar answered Sep 27 '22 16:09

harrietgrace