title: How to troubleshoot the error [The term 'pwsh.exe' is not recognized as the name of a cmdlet, function, script file, or operable program]?
body: <p>While creating a new pipeline on Azure DevOps to set up a CI for a .NET project, I set up the following PowerShell script to automate the .NET Core setup.</p>
  <p>Here is the script:</p>
  <pre><code>$ErrorActionPreference=&quot;Stop&quot;
  $ProgressPreference=&quot;SilentlyContinue&quot;
  
  # $LocalDotnet is the path to the locally-installed SDK to ensure the
  #   correct version of the tools are executed.
  $LocalDotnet=&quot;&quot;
  # $InstallDir and $CliVersion variables can come from options to the
  #   script.
  $InstallDir = &quot;./cli-tools&quot;
  $CliVersion = &quot;1.0.1&quot;
  
  # Test the path provided by $InstallDir to confirm it exists. If it
  #   does, it's removed. This is not strictly required, but it's a
  #   good way to reset the environment.
  if (Test-Path $InstallDir)
  {
      rm -Recurse $InstallDir
  }
  New-Item -Type &quot;directory&quot; -Path $InstallDir
  
  Write-Host &quot;Downloading the CLI installer...&quot;
  
  # Use the Invoke-WebRequest PowerShell cmdlet to obtain the
  #   installation script and save it into the installation directory.
  Invoke-WebRequest `
      -Uri &quot;https://dot.net/v1/dotnet-install.ps1&quot; `
      -OutFile &quot;$InstallDir/dotnet-install.ps1&quot;
  
  Write-Host &quot;Installing the CLI requested version ($CliVersion) ...&quot;
  
  # Install the SDK of the version specified in $CliVersion into the
  #   specified location ($InstallDir).
  &amp; $InstallDir/dotnet-install.ps1 -Version $CliVersion `
      -InstallDir $InstallDir
  
  Write-Host &quot;Downloading and installation of the SDK is complete.&quot;
  
  # $LocalDotnet holds the path to dotnet.exe for future use by the
  #   script.
  $LocalDotnet = &quot;$InstallDir/dotnet&quot;
  </code></pre>
  <p>When I try to run the build, I have got the following error:</p>
  <p><a href="https://i.stack.imgur.com/hBoys.png" rel="noreferrer"><img src="https://i.stack.imgur.com/hBoys.png" alt="The error itself" /></a></p>
  <p>and</p>
  <p><a href="https://i.stack.imgur.com/oxw7V.png" rel="noreferrer"><img src="https://i.stack.imgur.com/oxw7V.png" alt="The error itself (verbose)" /></a></p>
  <p>I've already searched on Google for people who have the same problem and how to fix it. But I haven't found much information yet. The Azure DevOps forum doesn't help either.</p>