I want to know the difference between executing PowerShell script in C#
using the Pipeline
class versus the PowerShell
class.
Using Pipeline :
Pipeline pipe = runspace.CreatePipeline();
Using PowerShell class:
PowerShell ps = PowerShell.Create();
We can use both of them to execute PowerShell script in C#, but what is the difference between them?
You should read the documentation. A pipeline
is a feature of a runspace
. The PowerShell.Create()
method will create a PowerShell
object, a kind of wrapper for everything contained. Both of these methods belong to the same PowerShell SDK.
The Pipeline
is intended to run commands and is underneath the runspace
object.