title: Start-Process is not recognized when running powershell script from C# code
body: <p>I have the following code which stops IIS Application pool by executing Powershell script: </p>
  
  <pre><code>        using (PowerShell ps = PowerShell.Create())
          {
              ps.AddScript("Set-ExecutionPolicy -Scope LocalMachine Unrestricted");
              string stopCommand = File.ReadAllText($"{scriptPath}StopIISPool.ps1");                
              ps.AddScript(stopCommand);
              ps.AddScript($"StopIISAppPool -StopScriptPath {scriptPath}IISStopCommand.ps1 -poolName {paths.IISAppPoolName}");
              ps.Invoke();
  
              Collection&lt;ErrorRecord&gt; errors = ps.Streams.Error.ReadAll();
          }
  </code></pre>
  
  <p>And here StopIISPool.ps1 contains the following powershell script:</p>
  
  <pre><code>    function StopIISAppPool
      {
          Param(
          [parameter(Mandatory=$true)]
          [string]$stopScriptPath,
          [parameter(Mandatory=$true)]
          [string]$poolName
          )
          process
          {
              PowerShell.exe -NoProfile -ExecutionPolicy Unrestricted -Command "&amp;  {Start-Process PowerShell -windowstyle hidden -ArgumentList '-NoProfile -ExecutionPolicy Unrestricted -noexit -File $stopScriptPath -poolName $poolname' -Verb RunAs}";
          }
     }
  </code></pre>
  
  <p>And here stopScriptPath is the path of the following command which executes without errors only with elevated permissions:</p>
  
  <pre><code>    Param(
          [parameter(Mandatory=$true)]
          [string]$poolName
      )
      Stop-WebAppPool -Name $poolName;
  </code></pre>
  
  <p>The above C# code runs in ASP.NET Core application. 
  When I deploy the application under IIS on Windows Server 2012 R2 and run I get the following error on ps.Invoke() line:</p>
  
  <p><strong><em>Start-Process is not recognized as the name of a cmdlet, function, script file, or operable program.</em></strong> </p>
  
  <p>Could someone please explain why I get that error?</p>