Good day!
Trying to install azure AZ module on my windows 10 machine getting below error. any help and suggestions appreciate. thank you.
PS C:\WINDOWS\system32> Install-Module -Name Az -AllowClobber
NuGet provider is required to continue
PowerShellGet requires NuGet provider version '2.8.5.201' or newer to interact with NuGet-based repositories. The NuGet
provider must be available in 'C:\Program Files\PackageManagement\ProviderAssemblies' or
'C:\Users\user\AppData\Local\PackageManagement\ProviderAssemblies'. You can also install the NuGet provider by running
'Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force'. Do you want PowerShellGet to install and import
the NuGet provider now?
[Y] Yes [N] No [S] Suspend [?] Help (default is "Y"): Yes
WARNING: Unable to download from URI 'https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409' to ''.
WARNING: Unable to download the list of available providers. Check your internet connection.
PackageManagement\Install-PackageProvider : No match was found for the specified search criteria for the provider
'NuGet'. The package provider requires 'PackageManagement' and 'Provider' tags. Please check if the specified package
has the tags.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:7468 char:21
+ ... $null = PackageManagement\Install-PackageProvider -Name $script:N ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (Microsoft.Power...PackageProvider:InstallPackageProvider) [Install-Pac
kageProvider], Exception
+ FullyQualifiedErrorId : NoMatchFoundForProvider,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackagePro
vider
PackageManagement\Import-PackageProvider : No match was found for the specified search criteria and provider name
'NuGet'. Try 'Get-PackageProvider -ListAvailable' to see if the provider exists on the system.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:7474 char:21
+ ... $null = PackageManagement\Import-PackageProvider -Name $script:Nu ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (NuGet:String) [Import-PackageProvider], Exception
+ FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.ImportPackageProv
ider
WARNING: Unable to download from URI 'https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409' to ''.
WARNING: Unable to download the list of available providers. Check your internet connection.
PackageManagement\Get-PackageProvider : Unable to find package provider 'NuGet'. It may not be imported yet. Try
'Get-PackageProvider -ListAvailable'.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:7478 char:30
+ ... tProvider = PackageManagement\Get-PackageProvider -Name $script:NuGet ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Microsoft.Power...PackageProvider:GetPackageProvider) [Get-PackageProvi
der], Exception
+ FullyQualifiedErrorId : UnknownProviderFromActivatedList,Microsoft.PowerShell.PackageManagement.Cmdlets.GetPacka
geProvider
Install-Module : NuGet provider is required to interact with NuGet-based repositories. Please ensure that '2.8.5.201'
or newer version of NuGet provider is installed.
At line:1 char:1
+ Install-Module -Name Az -AllowClobber
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Install-Module], InvalidOperationException
+ FullyQualifiedErrorId : CouldNotInstallNuGetProvider,Install-Module
#SumanthMarigowda-MSFT Thank you so much,finally able to install PowershellGet/Azure Powershell Module
[following https://learn.microsoft.com/en-us/powershell/azure/install-az-ps?view=azps-5.1.0
to install Azure Module on Powershell which needs Powershell Get which in turn needs NuGet]
PS C:\WINDOWS\system32> Install-Module -Name PowershellGet -Force
NuGet provider is required to continue
PowerShellGet requires NuGet provider version '2.8.5.201' or newer to interact with NuGet-based repositories. The NuGet provider must be available in 'C:\Program
Files\PackageManagement\ProviderAssemblies' or 'C:\Users\aditgarg\AppData\Local\PackageManagement\ProviderAssemblies'. You can also install the NuGet provider by running
'Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force'. Do you want PowerShellGet to install and import the NuGet provider now?
[Y] Yes [N] No [S] Suspend [?] Help (default is "Y"): N
Since it prompts to have NuGet installed,I cancel the above command and issue the command in above line:
PS C:\WINDOWS\system32> Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
WARNING: Unable to download from URI 'https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409' to ''.
WARNING: Unable to download the list of available providers. Check your internet connection.
Install-PackageProvider : No match was found for the specified search criteria for the provider 'NuGet'. The package provider requires 'PackageManagement' and 'Provider' tags. Please
check if the specified package has the tags.
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 : NoMatchFoundForProvider,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackageProvider
Your above solution fixes the NuGet Installation issue:
PS C:\WINDOWS\system32> [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Finally installing NuGet
PS C:\WINDOWS\system32>
PS C:\WINDOWS\system32> Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
Name Version Source Summary
nuget 2.8.5.208 https://onege... NuGet provider for the OneGet meta-package manager
PS C:\WINDOWS\system32>
Finally installing PowershellGet
PS C:\WINDOWS\system32> Install-Module -Name PowerShellGet -Force
PS C:\WINDOWS\system32>
PS C:\WINDOWS\system32>
PS C:\WINDOWS\system32> Get-InstalledModule -Name PowerShellGet
Version Name Repository Description
------- ---- ---------- -----------
2.2.5 PowerShellGet PSGallery PowerShell module with commands for discovering, installing, updating and publishing the PowerShell artifacts like Mo...
And now we can install the Azure PowerShell Module
PS C:\WINDOWS\system32>
if ($PSVersionTable.PSEdition -eq 'Desktop' -and (Get-Module -Name AzureRM -ListAvailable)) {
Write-Warning -Message ('Az module not installed. Having both the AzureRM and ' +
'Az modules installed at the same time is not supported.')
} else {
Install-Module -Name Az -AllowClobber -Scope CurrentUser
}
PS C:\WINDOWS\system32> Get-InstalledModule -Name Az
Version Name Repository Description
5.1.0 Az PSGallery Microsoft Azure PowerShell - Cmdlets to manage resources in Azure. This module is compatible with WindowsPowerShell a...
PS C:\WINDOWS\system32>
Adding my comments on issue encountered when trying to connect to Azure(login):
More issues:
PS C:\WINDOWS\system32> Connect-AzAccount
Do you want to run software from this untrusted publisher?
File C:\Users\aditgarg\Documents\WindowsPowerShell\Modules\Az.Accounts\2.2.1 \Accounts.format.ps1xml is published by CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond,
S=Washington, C=US and is not trusted on your system. Only run scripts from trusted publishers.
[V] Never run [D] Do not run [R] Run once [A] Always run [?] Help (default is "D"): Y
[V] Never run [D] Do not run [R] Run once [A] Always run [?] Help (default is "D"): A
Connect-AzAccount : The 'Connect-AzAccount' command was found in the module 'Az.Accounts', but the module could not be loaded. For more information, run 'Import-Module Az.Accounts'.
At line:1 char:1
+ Connect-AzAccount
+ ~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Connect-AzAccount:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CouldNotAutoloadMatchingModule
--trying to import the found module as suggested above--
PS C:\WINDOWS\system32> Import-Module -Name Az
Import-Module : File C:\Users\aditgarg\Documents\WindowsPowerShell\Modules \Az\5.1.0\Az.psm1 cannot be loaded because running scripts is disabled on this system. For more information, see
about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ Import-Module -Name Az
+ ~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : SecurityError: (:) [Import-Module], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess,Microsoft.PowerShell.Commands.ImportModuleCommand
PS C:\WINDOWS\system32>
Solution: https://learn.microsoft.com/en-us/troubleshoot/azure/active-directory/cannot-run-scripts-powershell as the above error basically says running scripts is disabled on this system
ie
PS C:\WINDOWS\system32> Set-ExecutionPolicy Unrestricted
Execution Policy Change
The execution policy helps protect you from scripts that you do not trust. Changing the execution policy might expose you to the security risks described in the about_Execution_Policies
help topic at https:/go.microsoft.com/fwlink/?LinkID=135170. Do you want to change the execution policy?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): Y
(press Y, A may pose security risk)
And now Connect-AzAccount works to connect to Azure(login).
Set the execution policy to Restricted after execution of commands:
Set-ExecutionPolicy restricted
The error is caused by the way Windows PowerShell interacts with the NuGet infrastructure delivering both the NuGet Package Provider and the Windows PowerShell Module.
The entire infrastructure is secured with SSL/TLS. This prevents eavesdropping and meddle in the middle-type attacks, where a malicious person with inject rogue code into a plain-text communication stream.
Windows PowerShell does not communicate with the infrastructure using TLS 1.2, but with a less secure encryption protocol. As with many other infrastructure, the NuGet infrastructure has switched off less secure encryption protocols. The best current way on Windows Server 2016 to interact with the infrastructure is using TLS 1.2.
To run the below cmdlets
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
You may also refer to this link
Note: the command only affects the current session and does not persist.
You may also check what version of TLS for client is set on computer. Looks like TLS 1.0 for client is required. (ref: https://powershell.org/forums/topic/wmf-5-1-upgrade-broken-repositories/)
TLS security related (ref: https://rnelson0.com/2018/05/17/powershell-in-a-post-tls1-1-world/)
Related
Any help is appreciated.
I am getting the error below when trying to execute the PowerShell script in Runbooks.
Invoke-ASCmd : The term 'Invoke-ASCmd' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:27 char:1 + Invoke-ASCmd -Query $TmslScript -Server: $XmlaEndpoint -Database $Dat ... + ~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Invoke-ASCmd:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
But when I execute the same script locally then it is successful.
Powershell executed locally
I tried to install the SqlServer module using the script:
Install-Module SqlServer -RequiredVersion 21.1.18230 -Scope CurrentUser -SkipPublisherCheck -AllowClobber -Force
but it gave me the errors below.
Error 1:
Exception calling "ShouldContinue" with "2" argument(s): "A command that prompts the user failed because the host program or the command type does not support user interaction. The host was attempting to request confirmation with the following message: PowerShellGet requires NuGet provider version '2.8.5.201' or newer to interact with NuGet-based repositories. The NuGet provider must be available in 'C:\Program Files\PackageManagement\ProviderAssemblies' or 'C:\Users\Client\AppData\Roaming\PackageManagement\ProviderAssemblies'. You can also install the NuGet provider by running 'Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force'. Do you want PowerShellGet to install and import the NuGet provider now?" At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:7455 char:8 + if($Force -or $psCmdlet.ShouldContinue($shouldContinueQueryMessag ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : HostException
Error 2:
Install-Module : NuGet provider is required to interact with NuGet-based repositories. Please ensure that '2.8.5.201' or newer version of NuGet provider is installed. At line:12 char:1 + Install-Module SqlServer -RequiredVersion 21.1.18230 -Scope CurrentUs ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [Install-Module], InvalidOperationException + FullyQualifiedErrorId : CouldNotInstallNuGetProvider,Install-Module
So, I tried to install the NuGet package using the script:
Install-PackageProvider -Name NuGet -Scope CurrentUser -Force
but it gave me the error below:
Install-PackageProvider : No match was found for the specified search criteria for the provider 'NuGet'. The package provider requires 'PackageManagement' and 'Provider' tags. Please check if the specified package has the tags. At line:11 char:1 + Install-PackageProvider -Name NuGet -Scope CurrentUser -Force + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (Microsoft.Power...PackageProvider:InstallPackageProvider) [Install-PackageProvider], Exception + FullyQualifiedErrorId : NoMatchFoundForProvider,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackageProvider
I tried installing the following scripts in succession hoping to resolve the issue:
PowerShell Install-PackageProvider -Name NuGet -Scope CurrentUser -Force
PowerShellInstall-Module SqlServer -RequiredVersion 21.1.18230 -Scope CurrentUser -SkipPublisherCheck -AllowClobber -Force
PowerShellInvoke-ASCmd -Query $TmslScript -Server: $XmlaEndpoint -Database $DatasetName
Error running the PowerShell script in Runbooks:
Reasons for error:
Need to check:
The term 'Invoke-ASCmd' is not recognized as the name of a cmdlet:
Add/import the required module by opening below path:
Azure Automation account -> Shared Resources -> Modules -> Add a module Search for sql server from PS Gallery and import.
If you are installing module with script, it is not installing properly sometimes. I suggest you add modules and then invoke Invoke-ASCmd command in runbook.
I tried to install SQL Server after importing, but it failed since "Administrator rights" were required.
To resolve this, You can run account as an administrator or assign managed identities.
I used the following command to assign a
'UserAssigned Managed Identity' to the Automation account:
set-azautomationaccount -Resourcegroupname "Jahnavi" -Name "Jahnaviauto" -AssignUserIdentity "/subscriptions/<SubscriptionID>/resourceGroups/Jahnavi/providers/Microsoft.ManagedIdentity/userAssignedIdentities/<UserIdentityName_user>"
Now, I installed using below command and it worked for me successfully:
Install-Module -Name SqlServer -AllowPrerelease -Force -Verbose -Scope CurrentUser
Exception calling "ShouldContinue" with "2" argument(s):
This error can occurs when you have a package installed in the list and attempt to override it with the required version again.
Use Moduleversionoverrides parameter in these cases.
I am following documentation https://learn.microsoft.com/en-us/azure/active-directory/b2b/direct-federation on Powershell and running below command:
Import-Module AzureAD
Connect-AzureAD
$federationSettings = New-Object Microsoft.Open.AzureAD.Model.DomainFederationSettings
I am getting following error:
PS C:\WINDOWS\system32> $federationSettings = New-Object Microsoft.Open.AzureAD.Model.DomainFederationSettings
New-Object : Cannot find type [Microsoft.Open.AzureAD.Model.DomainFederationSettings]: verify that the assembly
containing this type is loaded.
At line:1 char:23
+ ... nSettings = New-Object Microsoft.Open.AzureAD.Model.DomainFederationS ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidType: (:) [New-Object], PSArgumentException
+ FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand
DomainFederationSettings class seems to be missing
How can I have Microsoft.Open.AzureAD.Model.DomainFederationSettings loaded and execute command $federationSettings = New-Object Microsoft.Open.AzureAD.Model.DomainFederationSettings
at the time of writing this answer, you need to use AzureADPreview module and not AzureAd
I highly suspect you are trying this statement with the latter rather than the former.
To install
Install-Module -Name AzureADPreview -AllowClobber
(-AllowClobber is to allow the installation side-to-side with AzureAD module, if you have it installed)
To configure direct federation in Azure AD using PowerShell
Install the latest version of the Azure AD PowerShell for Graph module
(AzureADPreview). (If you need detailed steps, the quickstart for
adding a guest user includes the section Install the latest
AzureADPreview module.)
Source :
MS docs - Configure direct federation in azure ad using powershell
Unable to run windows update remotely via powershell
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
Install-Module -Name PSWindowsUpdate -Force
Import-Module -Name PSWindowsUpdate
Install-WindowsUpdate -KBArticleID KB890830,KB2267602 -Confirm:$false -AutoReboot
Error Message :
Install-Module : The term 'Install-Module' is not recognized as the name of a
cmdlet, function, script file, or operable program. Check the spelling of the
name, or if a path was included, verify that the path is correct and try again.
At C:\Packages\Plugins\Microsoft.CPlat.Core.RunCommandWindows\1.1.5\Downloads\s
cript4.ps1:3 char:1
Install-Module -Name PSWindowsUpdate -Force
+ CategoryInfo : ObjectNotFound: (Install-Module:String) [], Comm
andNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Looks like Windows Management Framework is missing at the target server. Please install it and try again
Windows Management Framework
Thanks,
Manu
I tried to get Azure Stack identity health report according to the below document. But getting error if the packages are installed on power shell.
Link
Get-AzsHealthReport : The term 'Get-AzsHealthReport' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included,
verify that the path is correct and try again.
At line:3 char:17
+ $healthReport = Get-AzsHealthReport -AdminResourceManagerEndpoint $Ad ...
+ ~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Get-AzsHealthReport:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Follow the steps provided in this document on powershell as Admin.
Start Powershell in Admin mode and run the below steps:
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
# Install the AzureRM.BootStrapper module. Select Yes when prompted to install NuGet
Install-Module -Name AzureRM.BootStrapper
# Install and import the API Version Profile required by Azure Stack into the current PowerShell session.
Use-AzureRmProfile -Profile 2019-03-01-hybrid -Force
Install-Module -Name AzureStack -RequiredVersion 1.7.2
Now install Azure Stack Tools:
https://github.com/Azure/AzureStack-Tools/tree/master/Identity#download-azure-stack-tools
cd C:
mkdir Azure-Stack
cd .\Azure-Stack\
# Download the tools archive.
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
invoke-webrequest `...
# Expand the downloaded files.
expand-archive master.zip `...
# Change to the tools directory.
cd AzureStack-Tools-master
cd .\Identity\
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
Import-Module ..\Connect\AzureStack.Connect.psm1
Import-Module ..\Identity\AzureStack.Identity.psm1
Get-AzsHealthReport
You should now be able to run the command.
Hope this helps!
$ Get-InstalledModule -Name Az -AllVersions
Version Name Repository Description
------- ---- ---------- -----------
0.5.0 Az PSGallery Azure Resource Manager Module. Cmdlets to manage...
Above block shows that Az is installed.. But following block says otherwise:
$ Update-Module -Name Az
WARNING: Unable to resolve package source 'https://www.powershellgallery.com/api/v2'.
PackageManagement\Install-Package : No match was found for the specified search criteria and module name 'Az'. Try
Get-PSRepository to see all available registered module repositories.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:2089 char:20
+ ... $sid = PackageManagement\Install-Package #PSBoundParameters
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Ex
ception
+ FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage
Thanks for help to everyone in comments... Here the main problem was the repository itself.. De-registering and registering it back solved the issue.
> Register-PSRepository -Default
Using TLS1.2 connection solved the issue. Try executing below command before installing module Az-
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Install-Module -Name Az -AllowClobber -Scope CurrentUser
In my case the following ways are not in effect.
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Register-PSRepository -Default
I resolved by installing newer version of AzureRM.
PS> Install-Module -Name AzureRM -AllowClobber