Open silverl opened 2 years ago
Also installed locally:
❯ Get-InstalledModule PackageManagement
Version Name Repository Description
------- ---- ---------- -----------
1.4.8.1 PackageManagement PSGallery PackageManagement (a.k.a. OneGet) is a new way to discover and install software packages from around the web.…
lsilverman@dev-lsilverman ~
❯ Get-InstalledModule powershellget
Version Name Repository Description
------- ---- ---------- -----------
2.2.5 PowerShellGet PSGallery PowerShell module with commands for discovering, installing, updating and publishing the PowerShell artifacts like Modules, DSC Resources, Role Capabilities and Scripts.
I threw in a task before ps-rule-assert@2
- task: AzurePowerShell@5
displayName: "Import-Module PowerShellGet"
condition: succeeded()
inputs:
azureSubscription: ${{parameters.subscriptionId}}
scriptType: inlineScript
errorActionPreference: 'Stop'
targetAzurePs: latestVersion
pwsh: true
inline: |
Import-Module PowerShellGet -Verbose
Get-InstalledModule PowerShellGet
The output:
VERBOSE: Populating RepositorySourceLocation property for module PowerShellGet.
VERBOSE: Loading module from path 'C:\Program Files\PowerShell\Modules\PowerShellGet\2.2.5\PSModule.psm1'.
VERBOSE: Importing function 'Find-Command'.
VERBOSE: Importing function 'Find-DscResource'.
VERBOSE: Importing function 'Find-Module'.
VERBOSE: Importing function 'Find-RoleCapability'.
VERBOSE: Importing function 'Find-Script'.
VERBOSE: Importing function 'Get-CredsFromCredentialProvider'.
VERBOSE: Importing function 'Get-InstalledModule'.
VERBOSE: Importing function 'Get-InstalledScript'.
VERBOSE: Importing function 'Get-PSRepository'.
VERBOSE: Importing function 'Install-Module'.
VERBOSE: Importing function 'Install-Script'.
VERBOSE: Importing function 'New-ScriptFileInfo'.
VERBOSE: Importing function 'Publish-Module'.
VERBOSE: Importing function 'Publish-Script'.
VERBOSE: Importing function 'Register-PSRepository'.
VERBOSE: Importing function 'Save-Module'.
VERBOSE: Importing function 'Save-Script'.
VERBOSE: Importing function 'Set-PSRepository'.
VERBOSE: Importing function 'Test-ScriptFileInfo'.
VERBOSE: Importing function 'Uninstall-Module'.
VERBOSE: Importing function 'Uninstall-Script'.
VERBOSE: Importing function 'Unregister-PSRepository'.
VERBOSE: Importing function 'Update-Module'.
VERBOSE: Importing function 'Update-ModuleManifest'.
VERBOSE: Importing function 'Update-Script'.
VERBOSE: Importing function 'Update-ScriptFileInfo'.
VERBOSE: Importing variable 'PSGetPath'.
VERBOSE: Importing alias 'fimo'.
VERBOSE: Importing alias 'inmo'.
VERBOSE: Importing alias 'pumo'.
VERBOSE: Importing alias 'upmo'.
Version Name Repository Description
------- ---- ---------- -----------
2.2.5 PowerShellGet PSGallery PowerShell module with commands for disc…
Added TLS 1.2 in session.
Disconnect-AzureRmAccount -Scope Process -ErrorAction Stop
Clear-AzureRmContext -Scope Process -ErrorAction Stop
Finishing: Import-Module PowerShellGet
@silverl Thanks for reporting the issue.
The task currently ships with support for PSRule v2.1.0. And will try to install this version.
To use PSRule v2.2.0.
Set the version:
property to 2.2.0
.
We can probably do better to provide an additional switch to accept newer versions. Thanks for the feedback.
If this doesn't solve the issue, let us know.
Otherwise let's keep the issue open and I'll look at providing an addition option to avoid pinning the version.
Description of the issue
My tasks were working fine in the Azure DevOps hosted agent.
I just installed the self-hosted agent locally on Windows 11 x64. I already have PSRule 2.2.0 and PSRule.Rules.Azure 1.17.1 installed.
The self-hosted agent runs as the NETWORK SERVICE user.
It looks like it might be trying to uninstall or reinstall the modules, and it's erroring out.
Configuration
Yaml configuration of the extension.
Expected behaviour
Expected it to work as it did in a hosted agent.
Error output
Task in use and version:
Additional context
I tried commenting out the
ps-rule-install
task, as I already have the modules installed locally.The next task,
ps-rule-assert
, failed in a similar manner as it too attempted to install the modules.I next attempted to uninstall the modules from my machine to see if I could progress. I was blocked again with a similar message that they were in use.
I closed all terminals and powershell sessions and stopped VSCode (in which I have the PSRule extension installed). This seemed to allow me to uninstall the modules and run the job again.
This time I'm getting the following: