I want to be clear about one thing that why we are using Runspace
while running the PowerShell scripts in C#
. It runs even though the absence of Runspace
.
If it can be run without the Runspace
why we need?
For eg:
PowerShell ps = PowerShell.Create();
ps.AddScript("Import-Module AzureAD");
This will work even though the absence of Runspace
. So Why is it?