When I try to run the script with my C# code. I get the following error:
"You cannot call a method on a null-valued expression."
Would this be my C# code that is wrong
Runspace runSpace = RunspaceFactory.CreateRunspace();
runSpace.Open();
RunspaceInvoke runSpaceInvoker = new RunspaceInvoke(runSpace);
Pipeline pipeLine = runSpace.CreatePipeline();
pipeLine.Commands.AddScript(@"D:\NewSites\test-new\ConfigureIIS7.ps1");
try
{
pipeLine.Invoke();
}
catch (Exception ex)
{
throw ex;
}
pipeLine.Stop();
runSpace.Close();
Or should I look for the problem in my powershell script? The shell script works when executed normally. Thanks in advance.