Reputation: 637
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?
Upvotes: 2
Views: 5341
Reputation: 19391
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
Here is the official document you can refer to.
Upvotes: 4
Reputation: 1885
Edit:
Install-module
should be Install-Module
.
Moreover,by restoring the PSRespository back to default your problem is hopefully resolved :)
Register-PSRepository -Default
Upvotes: 0