Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Devops yaml "The term '-powershell:' is not recognized"

I’d like my devops build pipeline to run PowerShell that will list files it later complains it can’t find.

When I run the following I get the error:

The term ‘-powershell:’ is not recognized

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Where did I go wrong?

name: Deploy Bicep files $(Build.BuildId)

trigger: none
# - main

variables:
  location: "uksouth"
  templateFile: "bicep/365Response.main.json"

pool:
  vmImage: "windows-latest"

stages:
  - stage: preDeploy
    variables:
      env: "dev"
    jobs:
      - job: listFiles
        displayName: List Files
        pool:
          vmImage: windows-2022

        steps:
          - task: PowerShell@2
            inputs:
              targetType: "inline"
              script: "-powershell: Get-ChildItem -Path '$(System.DefaultWorkingDirectory)' -recurse"

>Solution :

The error message is from PowerShell, telling you that -powershell is not a valid construct in PowerShell 🙂 And it’s not.

To me, that says that inside the script element you need a valid powershell snippet, such as:

Get-ChildItem -Path '$(System.DefaultWorkingDirectory)' -recurse
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading