azure - 在 Windows 10 上安装 Azure PowerShell 模块
问题描述
再会!
尝试在我的 Windows 10 机器上安装 azure AZ 模块时出现以下错误。任何帮助和建议表示赞赏。谢谢你。
PS C:\WINDOWS\system32> Install-Module -Name Az -AllowClobber
需要 NuGet 提供程序才能继续 PowerShellGet 需要 NuGet 提供程序版本“2.8.5.201”或更高版本才能与基于 NuGet 的存储库进行交互。NuGet 提供程序必须在“C:\Program Files\PackageManagement\ProviderAssemblies”或“C:\Users\user\AppData\Local\PackageManagement\ProviderAssemblies”中可用。您还可以通过运行“Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force”来安装 NuGet 提供程序。是否希望 PowerShellGet 现在安装和导入 NuGet 提供程序?[Y] 是 [N] 否 [S] 暂停 [?] 帮助(默认为“Y”):是 警告:无法从 URI 下载“ https://go.microsoft.com/fwlink/?LinkID=627338&clcid= 0x409' 至 ''。警告:无法下载可用提供程序的列表。检查您的互联网连接。PackageManagement\Install-PackageProvider:未找到与提供程序“NuGet”的指定搜索条件匹配的内容。包提供者需要“PackageManagement”和“Provider”标签。请检查指定的包裹是否有标签。在 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], 异常 + FullyQualifiedErrorId : NoMatchFoundForProvider,Microsoft.PowerShell。
PackageManagement\Import-PackageProvider :未找到指定搜索条件和提供程序名称“NuGet”的匹配项。尝试“Get-PackageProvider -ListAvailable”以查看系统上是否存在提供程序。在 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], 异常 + FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.ImportPackageProvider
警告:无法从 URI 下载https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409' 至 ''。警告:无法下载可用提供程序的列表。检查您的互联网连接。PackageManagement\Get-PackageProvider:找不到包提供程序“NuGet”。它可能尚未导入。尝试“Get-PackageProvider -ListAvailable”。在 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-PackageProvider], 异常 + FullyQualifiedErrorId : UnknownProviderFromActivatedList,Microsoft.PowerShell.PackageManagement.Cmdlets.GetPackageProvider
Install-Module :需要 NuGet 提供程序才能与基于 NuGet 的存储库进行交互。请确保安装了“2.8.5.201”或更新版本的 NuGet 提供程序。在 line:1 char:1 + Install-Module -Name Az -AllowClobber + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~ + CategoryInfo : InvalidOperation: (:) [Install-Module], InvalidOperationException + FullyQualifiedErrorId : CouldNotInstallNuGetProvider,Install-Module
解决方案
@SumanthMarigowda-MSFT 非常感谢,终于可以安装 PowershellGet/Azure Powershell 模块了
[按照 https://docs.microsoft.com/en-us/powershell/azure/install-az-ps?view=azps-5.1.0 在需要 Powershell Get 而需要 NuGet 的 Powershell 上安装 Azure 模块]
PS C:\WINDOWS\system32> Install-Module -Name PowershellGet -Force
需要 NuGet 提供程序才能继续 PowerShellGet 需要 NuGet 提供程序版本“2.8.5.201”或更高版本才能与基于 NuGet 的存储库进行交互。NuGet 提供程序必须在“C:\Program Files\PackageManagement\ProviderAssemblies”或“C:\Users\aditgarg\AppData\Local\PackageManagement\ProviderAssemblies”中可用。您还可以通过运行 'Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force'来安装 NuGet 提供程序。是否希望 PowerShellGet 现在安装和导入 NuGet 提供程序?[Y] 是 [N] 否 [S] 暂停 [?] 帮助(默认为“Y”):N
由于提示安装了 NuGet,我取消了上面的命令并在上面的行中发出命令:
PS C:\WINDOWS\system32> Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
警告:无法从 URI 'https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409' 下载到 ''。警告:无法下载可用提供程序的列表。检查您的互联网连接。Install-PackageProvider:找不到与提供程序“NuGet”的指定搜索条件匹配的内容。包提供者需要“PackageManagement”和“Provider”标签。请检查指定的包裹是否有标签。在行:1 字符: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
您的上述解决方案修复了 NuGet 安装问题:
PS C:\WINDOWS\system32> [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
最后安装 NuGet
PS C:\WINDOWS\system32>
PS C:\WINDOWS\system32> Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
名称 版本 来源 摘要
nuget 2.8.5.208 https://onege... OneGet 元包管理器的 NuGet 提供程序
PS C:\WINDOWS\system32>
最后安装 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...
现在我们可以安装 Azure PowerShell 模块
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>
添加我对尝试连接到 Azure(登录)时遇到的问题的评论:
更多问题:
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
--尝试按照上面的建议导入找到的模块--
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>
解决方案:https ://docs.microsoft.com/en-us/troubleshoot/azure/active-directory/cannot-run-scripts-powershell上面的错误基本上说在这个系统上运行脚本被禁用
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
(按 Y,A 可能会带来安全风险) 现在 Connect-AzAccount 可以连接到 Azure(登录)。
执行命令后将执行策略设置为 Restricted:Set-ExecutionPolicy restricted
推荐阅读
- qt - 更新 QQuickImageProvider 请求
- java - TransactionAttribute.REQUIRES_NEW 未使用容器管理事务在 EJB bean 中启动新事务
- arrays - Test-Connection $False 不会转换为 ArrayList
- python - bqplot 和 ipywidget 滑块,最大递归深度
- vb6 - 从用户控制内部检查自我可见性
- r - R - 为列表中的每个数据框添加一个新 ID(使用 apply 或 dplyr)
- mysql - 在 mysql 中使用限制和更新
- java - 使用 Java 的相互身份验证(带客户端证书 PFX 文件)并且无法访问环境
- node.js - 使用 X-Ray-Scraper 刮取背景图像
- javascript - 在根问题上反应嵌套路由