Open onetocny opened 1 week ago
(I'm not a maintainer, just a curious user.)
On the client part when this happens, what is the output of:
# List paths PowerShell will use to check for loading modules
[System.Environment]::GetEnvironmentVariable('PSModulePath','Process').Split(';')
# Can PowerShellGet and PSResourceGet be found?
Get-Module -ListAvailable -Name 'PowerShellGet', 'Microsoft.PowerShell.PSResourceGet' |
Sort-Object -Property 'Name', 'Version' |
Format-List -Property 'Name', 'Version', 'Path'
I'd also recommend using Install-PSResource
( https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.psresourceget/install-psresource ) of PSResourceGet ( https://github.com/PowerShell/PSResourceGet ), as PowerShellGet and PackageManagement has been superseded.
I think PowerShellGet v3 is meant to create backward compatible aliases to PSResourceGet ( PowerShellGet\Install-Module
=> Microsoft.PowerShell.PSResourceGet\Install-PSResource
), but it does not look finished / still in beta:
Edit: Maybe relevant, seems you combine PSModulePath in function Update-PSModulePathForHostedAgentLinux
with :
, not semicolon ;
? 🤔
@dolauli to reproduce
Description
We are the team that maintains AzurePowerShell task for Azure Pipelines. Under the hood the task is using
Az.Accounts
module to authenticate against Azure and then calls the client script. Recently we started to see several customers having intermittent issues with missingInstall-Module
command when trying to use it within the client script of the AzurePowerShell task (see the issue script section).The issue occurs in approximately one quarter of all cases on Ubuntu 22.04 (see the environment data table below). We did some investigation and found out that
Install-Module
command becomes unavailable once theClear-AzContext
is called. Also we noticed that callingGet-Command "Install-Module" -ErrorAction SilentlyContinue
mitigates the issue andInstall-Module
becomes available again. This approach was used as an immediate hotfix.Issue script & Debug output
Environment data
Module versions
Error output
There are no errors in Az module.