Installing modules

I am trying to obtain either the AzureRM cmdlets or MSonline cmdlets (don’t know how much they differ) yet I am having difficulty. On a Windows 2012 R2, I upgraded to Windows Management Framework 5.1 and my $psversiontable records PSVersion at 5.1.14409.1005 with CLRVersion 4.0.30319.42000.

Following the steps in https://docs.microsoft.com/en-us/powershell/azure/install-azurerm-ps?view=azurermps-5.0.0
I execute the Get-Module PowershellGet and here is what I have,
PowerShellGet 1.0.0.1 C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PowerShellGet.psd1

I then execute, “Install-Module AzureRM -AllowClobber”
and I get the dialogue, “NuGet provider is required to continue” which informs me that I require NuGet provider version 2.8.5.201 or greater. It asks me if I want to import the NuGet provider now and I say ‘YES’. I then get a series of red errors starting off with "Unable to find repository with SourceLocation ‘’. Use Get-PSRepository to see all available repositories.
Fine, continuing along another one of MSFT’s endless rabbit holes, here is what I get when I run Get-PSRepository:

PackageManagement\Get-PackageSource : Unable to find module providers (PowerShellGet).
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:4458 char:31

  • … ckageSources = PackageManagement\Get-PackageSource @PSBoundParameters
  •                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidArgument: (Microsoft.Power…etPackageSource:GetPackageSource) [Get-PackageSource], Exception
    • FullyQualifiedErrorId : UnknownProviders,Microsoft.PowerShell.PackageManagement.Cmdlets.GetPackageSource

Any help on how I can get these modules loaded in my machine would be much appreciated.

p.s. I tried to manually “Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force” and receive:
Install-PackageProvider : Unable to find repository with SourceLocation ‘’. Use Get-PSRepository to see all available repositories.
At line:1 char:1

  • Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
  •   + CategoryInfo          : InvalidArgument: (Microsoft.Power...PackageProvider:InstallPackageProvider) [Install-PackageProvider], Exception
      + FullyQualifiedErrorId : RegisterPackageSourceRequired,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackageProvider

You’ve really done a few things that are not really needed and there are things that you should.
If you are using ad default install of W2K12+, PowerShellGet is not part of it, because it only has poSH v4. You either have to download and install PowerShellGet or install PowerShell v5+ (you’ve already done) which has it already.

For W2K12+ you only need to install the Azure cmdlets, install the MSOnline sign in assistant and use the MSOnline sign-in assistant to connect to azure and use the Azure cmdlets.

Install and configure Azure PowerShell
docs.microsoft.com/en-us/powershell/azure/install-azurerm-ps?view=azurermps-5.0.0

PowerShellGet has nothing to do with O365 or Azure specifically. It’s just a way to find, save, install and use modules / scripts from the PowerShellGallery. PoSHGet is MS implementation of Nuget (it installs and uses it under the covers), so no reason to separately install it to use Azure cmdlets or any other module in the PowerShellGallery.

Running the cmdlet Get-Module, just list the modules you have already on your system.
Find-Module allows you to lookup modules in the PowerShellGallery. Again, neither of those two have anything to do with Azure / O365.

To log on to Azure / O365, you just need this…
$CredsCloudAdmin = Get-Credential -Credential “GlobalAdminAccountName@$env:USERDOMAIN.onmicrosoft.com”

Environment setup

Connect-MsolService -Credential $CredsCloudAdmin

Import-Module -Name MSOnline

Import-Module -Name MSOnlineExtended

Connect-AzureAD -Credential $CredsCloudAdmin

Import-Module -Name AzureAD

Import-Module -Name AzureADPreview

I came across this problem on my computers at work. Even after installing WMF 5.1 the problem persisted. All my research pointed to a bug with the PackageManagement or PowershellGet modules. Unfortunately the only thing that fixed it for me was to find a computer with PowershellGet working and copy over the PackageManagement and PowershellGet modules. If you happen to zip them and put them on the internet somewhere don’t forget to run Unblock-File on the zip before you extract everything. Hope this helps.