2

I have the following PowerShell cmdlet to install PowerShell module when the pipeline is being executed

steps:
    - powershell: |
    
        Install-PackageProvider Nuget -Scope CurrentUser -Force
        Install-module PSScriptAnalyzer -force -Scope CurrentUser
        Install-module PSPesterTest -force -Scope CurrentUser
      displayName: 'Install required PowerShell modules'

This however throws an error of "No repository with the name 'PSGallery' was found". Please, can anyone, point me to a workaround with regards this issue?

2 Answers 2

5

There are some problems with your script syntax, please try the following script:

pool:
  vmImage: 'windows-2019'

steps:

- task: PowerShell@2
  inputs:
    targetType: 'inline'
    script: |
      Install-PackageProvider -Name NuGet -Force -Scope CurrentUser
      Install-Module -Name PSScriptAnalyzer -Force -Scope CurrentUser
      Install-Module -Name PSPesterTest -Force -Scope CurrentUser

enter image description here

Here is the official document you can refer to.

Sign up to request clarification or add additional context in comments.

Comments

0

Edit:

Install-module should be Install-Module. Moreover,by restoring the PSRespository back to default your problem is hopefully resolved :)

Register-PSRepository -Default

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.