Powershell: Install-Module errors on install of Azure and AzureRM modules - MacOsX

Created on 18 Aug 2016  路  15Comments  路  Source: PowerShell/PowerShell

Steps to reproduce

Run command Install-Module Azure or Install-Module AzureRM

Expected behavior

Install PowerShell module for interacting with Azure using Azure and AzureRM commandlets

Actual behavior

Receive following error code

PackageManagementInstall-Package : Unable to find module providers (PowerShellGet).
At /usr/local/microsoft/powershell/6.0.0-alpha.9/Modules/PowerShellGet/PSModule.psm1:1706 char:21

  • ... $null = PackageManagementInstall-Package @PSBoundParameters
  • ~~~~~~~~~~~~

    • CategoryInfo : InvalidArgument: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Except

      ion

    • FullyQualifiedErrorId : UnknownProviders,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage

Environment data

> $PSVersionTable

Name Value


PSVersion 6.0.0-alpha
PSEdition Core
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 3.0.0.0
GitCommitId v6.0.0-alpha.9
CLRVersion
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

Area-PowerShellGet OS-macOS Resolution-External

Most helpful comment

I followed @alexandair's advice and it worked. A step by step though is that you'll need to do the following. (I also put the modules in my home directory, not sure if that is correct)

  1. Install-Package -Name AzureRM.NetCore.Preview -Source https://www.powershellgallery.com/api/v2/ -ProviderName NuGet -ExcludeVersion -Destination $home/powershell/modules
  2. Import-Module $home/powershell/modules/AzureRM.Profile.NetCore.Preview
  3. Import-Module $home/powershell/modules/AzureRM.Resources.NetCore.Preview
  4. Import-Module $home/powershell/modules/AzureRM.NetCore.Preview
  5. Login-AzureRmAccount

Note: When I ran the command Get-Module -ListAvailable AzureRM was not in the list and it seems that when you exit Powershell the AzureRM module goes away. Also, before I started I upgraded dotnet to version 1.0.0-preview3-003246

All 15 comments

Can you try 'Register-PSRepository -Default', then retry the repro?
After that, I suspect you are going to hit this issue: https://github.com/PowerShell/PowerShell/issues/1693

Received the same error, and I have verified that the PSModule.psm1 file exists at this path.

PackageManagementRegister-PackageSource : Unable to find module providers (PowerShellGet).
At /usr/local/microsoft/powershell/6.0.0-alpha.9/Modules/PowerShellGet/PSModule.psm1:4107 char:17

  • ... $null = PackageManagementRegister-PackageSource @PSBoundParamete ...
  • ~~~~~~~~~~~~~

    • CategoryInfo : InvalidArgument: (Microsoft.Power...erPackageSource:RegisterPackageSource) [Register-PackageS

      ource], Exception

    • FullyQualifiedErrorId : UnknownProviders,Microsoft.PowerShell.PackageManagement.Cmdlets.RegisterPackageSource

Although not quite you are also likely to hit the issue in #1773 as well as Install-Module is not currently working due to version type changes in these builds

I receive the same error when trying Register-PsRepository -Default

@JoshLuedeman Please use one of the following options to install the modules.

Option 1: Replace the PSModule.psm1 file under PowerShellGet module base with the updated file from master branch (https://github.com/PowerShell/PowerShell).

Install-Module error got resolved by adding a workaround in PowerShellGet module.
Please replace the PSModule.psm1 file under PowerShellGet module base with https://github.com/PowerShell/PowerShell/blob/master/src/Modules/Shared/PowerShellGet/PSModule.psm1.
For more details --> #1927

Option 2: Get the latest CI build

https://ci.appveyor.com/project/PowerShell/powershell/build/artifacts
    OR
https://travis-ci.org/PowerShell/PowerShell/builds/ 

Option 3: Use NuGet provider to install the required module to the target location.

Install-Package -Name $ModuleName -Source https://www.powershellgallery.com/api/v2/ -ProviderName NuGet -ExcludeVersion -Destination $YourTargetLocation

@bmanikm seeing the same behavior, can confirm option 1 does not remediate.

I managed to get the AzureRM module to install by ensuring that the .NET core was installed, and by making sure to run powershell with sudo.
I cannot get powershell to import the AzureRM module, though, which I think is related to the fact that AzureRM targets the full .NET and .NET Core doesn't yet work.
I get the following error:

Import-Module -Name AzureRM -Verbose
VERBOSE: Loading module from path '/usr/local/microsoft/powershell/6.0.0-alpha.9/Modules/AzureRM/2.0.1/AzureRM.psd1'.

Import-Module : The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)
At line:1 char:1
+ Import-Module -Name AzureRM -Verbose
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Import-Module], FileLoadException
    + FullyQualifiedErrorId : System.IO.FileLoadException,Microsoft.PowerShell.Commands.ImportModuleCommand

@jimbrookski There are new AzureRM modules refactored to work on CoreCLR. Try Option 3 (Install-Package) from @bmanikm response above and specify AzureRM.NetCore.Preview as the name of the module.

I followed @alexandair's advice and it worked. A step by step though is that you'll need to do the following. (I also put the modules in my home directory, not sure if that is correct)

  1. Install-Package -Name AzureRM.NetCore.Preview -Source https://www.powershellgallery.com/api/v2/ -ProviderName NuGet -ExcludeVersion -Destination $home/powershell/modules
  2. Import-Module $home/powershell/modules/AzureRM.Profile.NetCore.Preview
  3. Import-Module $home/powershell/modules/AzureRM.Resources.NetCore.Preview
  4. Import-Module $home/powershell/modules/AzureRM.NetCore.Preview
  5. Login-AzureRmAccount

Note: When I ran the command Get-Module -ListAvailable AzureRM was not in the list and it seems that when you exit Powershell the AzureRM module goes away. Also, before I started I upgraded dotnet to version 1.0.0-preview3-003246

Great, works corretly but it's very important...we need use for example the following commands:

Get-AzureService
Get-AzureVM
Set-AzureLoadBalancedEndpoint

@dfr0 - you'll need to raise this in the Azure Powershell repo over at https://github.com/azure/azure-powershell as this isn't a PowerShell issue

This issue was moved to PowerShell/PowerShellGet#24

note: On OSX 10.11.6, I'm getting:

Install-Package : Unable to find package source 
'https://www.powershellgallery.com/api/v2/'. Use Get-PackageSource to see all 
available package sources.

This is with PS 6 alpha 15
Dot net 1.1 was installed from dotnet-dev-osx-x64.1.0.0-preview2-1-003177.pkg

Above Option 3 using NuGet works.

We should close this issue.

I can install both Azure module and any package without any issues.
No issues with PowerShell Gallery nor NuGet.

:)

MacOS/Linux/Windows All Good!

Was this page helpful?
0 / 5 - 0 ratings