Skip to content

##[error]The term 'pwsh.exe' is not recognized as the name of a cmdlet, function, script file, or operable program. #52

@PitterG

Description

@PitterG

I've followed the whitepaper for installing and configuring.
I'm using a self-hosted DevOps Agent running only Powershell 5.1

As I understand, all installations should be using powershell 5.1 only.
But...
when running build pipeline for the very first time i get an errror on the 'Prepare Agent (Install Modules)' task.

Starting: Prepare Agent (Install Modules)

Task : PowerShell
Description : Run a PowerShell script on Linux, macOS, or Windows
Version : 2.262.0
Author : Microsoft Corporation
Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/powershell

Generating script.
Formatted command: . 'C:_M365DSC\agent_work\1\s\CICD\Scripts\DeployModules.ps1'
##[error]The term 'pwsh.exe' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Finishing: Prepare Agent (Install Modules)

Looking into 'build-template.yaml' i see the following configuration for the powershell task

  # Make sure all required modules are installed
  - task: PowerShell@2
    displayName: 'Prepare Agent (Install Modules)'
    inputs:
      targetType: 'filePath'
      filePath: './CICD/Scripts/DeployModules.ps1'
      errorActionPreference: 'Stop'
      failOnStderr: true
      pwsh: true

Setting pwsh is set to true. This means that the task should be run with powershell core and not with powershell.exe.

So do I have to install powershell 7.x on my agent or can I simply the the parameter 'pwsh' to false?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions