macos image: PowerShell: Install-Module does not work

Florian Feldhaus's Avatar

Florian Feldhaus

03 Aug, 2020 07:38 PM

The macos image is really great, but unfortunately it does not allow to run Install-Module in PowerShell which is very important to install the Pester testing framework. Doing so results in the following error:

Install-Module Pester -Scope CurrentUser -Force -SkipPublisherCheck -MinimumVersion 4.4.4 -MaximumVersion 4.999
Install-Package: /usr/local/microsoft/powershell/7/Modules/PowerShellGet/PSModule.psm1:9709
Line |
9709 |  … talledPackages = PackageManagement\Install-Package @PSBoundParameters
     |                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Administrator rights are required to install or update. Log on to the computer with an account that has Administrator rights, and then try again, or install by adding "-Scope CurrentUser" to your command. You can also try
     | running the Windows PowerShell session with elevated rights (Run as Administrator).

The problem seems to be that the PSGallery repository, which is available by default in PowerShell has InstallationPolicy set to untrusted:

Name                      : PSGallery
SourceLocation            :
Trusted                   : False
Registered                : True
InstallationPolicy        : Untrusted
PackageManagementProvider : NuGet
PublishLocation           :
ScriptSourceLocation      :
ScriptPublishLocation     :
ProviderOptions           : {}

Is it possible to change the InstallationPolicy to trusted in the macos image like it is with all other images? If not, why is it not possible?

  1. Support Staff 1 Posted by Feodor Fitsner on 04 Aug, 2020 12:46 AM

    Feodor Fitsner's Avatar

    Hi Florian,

    Do you have a repro appveyor.yml for this issue?

  2. 2 Posted by Florian Feldhau... on 04 Aug, 2020 10:28 AM

    Florian Feldhaus's Avatar

    Sure, here is the repo:

    Here is the test with 4 images:

    Only the macos image has the problem:

    BTW: I was very surprised to see that Visual Studio 2019 shows PowerShell 5.1:

    The "Software pre-installed on Windows build VMs" list only mentions PowerShell 7:

  3. 3 Posted by jakewmorrison on 28 Aug, 2020 03:57 AM

    jakewmorrison's Avatar

    Seeing a similar issue on my project.



    This was not occurring when the MacOS was running
    PSVersion 6.2.4

    But now it is running:
    PSVersion 7.0.1

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:


Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac