tag:help.appveyor.com,2012-11-13:/discussions/problems/27869-macos-image-powershell-install-module-does-not-workAppVeyor: Discussion 2020-09-16T20:20:28Ztag:help.appveyor.com,2012-11-13:Comment/485070732020-08-03T19:38:36Z2020-08-03T19:38:37Zmacos image: PowerShell: Install-Module does not work<div><p>The macos image is really great, but unfortunately it does not allow to run <code>Install-Module</code> in PowerShell which is very important to install the <a href="https://pester.dev/">Pester</a> testing framework. Doing so results in the following error:<br></p>
<pre>
<code>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).</code>
</pre>
<p>The problem seems to be that the PSGallery repository, which is available by default in PowerShell has InstallationPolicy set to untrusted:<br></p>
<pre>
<code>
Get-PSRepository
Name : PSGallery
SourceLocation : https://www.powershellgallery.com/api/v2
Trusted : False
Registered : True
InstallationPolicy : Untrusted
PackageManagementProvider : NuGet
PublishLocation : https://www.powershellgallery.com/api/v2/package/
ScriptSourceLocation : https://www.powershellgallery.com/api/v2/items/psscript
ScriptPublishLocation : https://www.powershellgallery.com/api/v2/package/
ProviderOptions : {}</code>
</pre>
<p>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?</p></div>Florian Feldhaustag:help.appveyor.com,2012-11-13:Comment/485070732020-08-04T00:46:36Z2020-08-04T00:46:36Zmacos image: PowerShell: Install-Module does not work<div><p>Hi Florian,</p>
<p>Do you have a repro appveyor.yml for this issue?</p></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/485070732020-08-04T10:28:45Z2020-08-04T10:28:46Zmacos image: PowerShell: Install-Module does not work<div><p>Sure, here is the repo:<br>
<a href="https://github.com/ffeldhaus/appveyor">https://github.com/ffeldhaus/appveyor</a></p>
<p>Here is the test with 4 images:<br>
<a href="https://ci.appveyor.com/project/ffeldhaus/appveyor">https://ci.appveyor.com/project/ffeldhaus/appveyor</a></p>
<p>Only the macos image has the problem:<br>
<a href="https://ci.appveyor.com/project/ffeldhaus/appveyor/build/job/m0ih17a5we9f18rm">https://ci.appveyor.com/project/ffeldhaus/appveyor/build/job/m0ih17...</a></p>
<p>BTW: I was very surprised to see that Visual Studio 2019 shows PowerShell 5.1:<br>
<a href="https://ci.appveyor.com/project/ffeldhaus/appveyor/build/job/g1q8nltp48h4tmdj">https://ci.appveyor.com/project/ffeldhaus/appveyor/build/job/g1q8nl...</a></p>
<p>The "Software pre-installed on Windows build VMs" list only mentions PowerShell 7:<br>
<a href="https://www.appveyor.com/docs/windows-images-software/">https://www.appveyor.com/docs/windows-images-software/</a></p></div>Florian Feldhaustag:help.appveyor.com,2012-11-13:Comment/485070732020-08-28T03:57:45Z2020-08-28T03:57:45Zmacos image: PowerShell: Install-Module does not work<div><p>Seeing a similar issue on my project.</p>
<p>Build: <a href="https://ci.appveyor.com/project/techthoughts2/poshgram">https://ci.appveyor.com/project/techthoughts2/poshgram</a></p>
<p>Repo: <a href="https://github.com/techthoughts2/PoshGram/tree/Enhancements">https://github.com/techthoughts2/PoshGram/tree/Enhancements</a></p>
<p>This was not occurring when the MacOS was running<br>
PSVersion 6.2.4</p>
<p>But now it is running:<br>
PSVersion 7.0.1</p></div>jakewmorrison