azure - 术语“Register-AzResourceProvider”未被识别为 cmdlet 的名称
问题描述
嗨,我正在尝试自学 Azure,我正在遵循本指南:https ://docs.microsoft.com/en-us/learn/modules/intro-to-governance/2-azure-policy 。我在 Windows 10 上$PSVersionTable.PSEdition
=Desktop
我向 Microsoft 支持发送了消息,但没有人回复。当我尝试跑步时
# Register the resource provider if it's not already registered
Register-AzResourceProvider -ProviderNamespace 'Microsoft.PolicyInsights'
我明白了
Register-AzResourceProvider : The term 'Register-AzResourceProvider' 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.
我已检查是否安装了 Azure powershell
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
}
对此的任何帮助将不胜感激。
解决方案
要解决此问题,请尝试按照以下步骤操作。
1.通过打开一个新的powershell会话Run as administrator
,然后运行下面的命令。
Install-Module -Name Az -AllowClobber -Scope AllUsers -Force
2.安装模块后,关闭管理员会话并打开一个新的普通powershell会话,然后登录您的用户帐户,该帐户有权注册提供者,例如Owner
订阅。
Connect-AzAccount
3.然后注册提供者。
Register-AzResourceProvider -ProviderNamespace 'Microsoft.PolicyInsights'
注意:如果问题仍然存在,请使用Get-Module
检查Az.Resources
模块是否在此powershell会话中导入(通常会自动导入),如果没有,您可以使用Import-Module -Name Az.Resources -Force
手动导入。
推荐阅读
- javascript - 如何使用 node.js GOT http 请求库进行故障排除?
- gradle - 如何在 buildFinished 中使用 commandLine()
- express - Node.js 快速重定向到另一个页面
- javascript - (7) 连接localhost 3000端口失败:连接被拒绝
- flutter - Flutter Dart - 如何制作一个带有向外边界Radius.circular(20)而不是向内的容器?
- python - python 多处理 pool.apply_async
- tensorflow - 在 tf.keras 中使用预训练模型进行预测
- angular - 如何使用providin:角度9中的“平台”
- python - 考虑到不同值的#的python分箱排序
- azure - 无法在 azure media services v3 中使用两个视频对资产进行编码