microsoft / PSRule

Validate infrastructure as code (IaC) and objects using PowerShell rules.

Home Page:https://microsoft.github.io/PSRule/v2/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Switch to using PSResourceGet for module installation + add PSGallery as repository if not present.

o-l-a-v opened this issue · comments

Is your feature request related to a problem? Please describe.

Run /home/runner/work/_actions/microsoft/ps-rule/v2.9.0/powershell.ps1 -InputType 'repository' -InputPath '' -Modules 'PSRule.Rules.Azure' -Source '.ps-rule/' -Baseline '' -Conventions '' -Option '' -Outcome '' -OutputFormat 'Sarif' -OutputPath 'results.sarif' -Path '' -PreRelease 'false' -Repository 'PSGallery' -Summary 'true' -Version '' [info] Using repository: PSGallery [info] Installing PSRule: 2.9.0 Get-PackageSource: Unable to find repository 'PSGallery'. Use Get-PSRepository to see all available repositories. Error: Process completed with exit code 1

Describe the solution you'd like

PSResourceGet is the successor to PowerShellGet and PackageManagement. It's included in the GitHub workers. Use it.

  • Edit: Seems you are using it already through aliases? Better to use the native cmdlets then IMO. :)

As the error shows: Add PSGallery as repository if not already present. It can be done with Register-PSRepository -Default, ref:

Describe alternatives you've considered

Install modules in the GitHub action before running the psrule step.

Additional context

Thanks for raising your first issue, the team appreciates the time you have taken 😉