Share via

Why cant I use installed PowerShell module on windows-latest but can on ubuntu-latest VM image?

Robert Moorcroft 0 Reputation points
2024-05-15T13:16:18.42+00:00

Im running a pipeline in devops and when using 'windows-latest' as the vm image it has the module Az.Accounts version 2.17.0 as default so I used the line :

Install-Module -Name Az.Accounts -RequiredVersion 2.19.0 -Repository PSGallery -Force



However it still uses the 2.17.0 and it causes the pipeline to fail because it needs 2.19.0. However if I just switch the vm image to 'ubuntu-latest' it uses the 2.19.0 version, why is this?

Windows for business | Windows Server | User experience | PowerShell
0 comments No comments

1 answer

Sort by: Most helpful
  1. Anonymous
    2024-05-16T02:11:05.88+00:00

    Hi Robert Moorcroft,

    Thanks for your post.

    It's not unusual for different images to have different versions of packages. You can specify the version of the module to be imported.

    Import-Module -Name Az.Accounts -RequiredVersion 2.19.0
    

    Or you can uninstall the older version of the package.

    Uninstall-Module -Name Az.Accounts -RequiredVersion 2.17.0
    

    Best Regards,

    Ian Xue


    If the Answer is helpful, please click "Accept Answer" and upvote it.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.