调用Invoke-AzOperationalInsightsQuery提示无法识别命令问题求解
Invoke-AzOperationalInsightsQuery: The term 'Invoke-AzOperationalInsightsQuery' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
问题根因
该报错是因为当前PowerShell环境未安装、未加载包含Invoke-AzOperationalInsightsQuery命令的Azure官方模块。
解决步骤
- 第一步:以管理员身份启动PowerShell,更新基础依赖模块
Install-Module -Name PowerShellGet -Force -AllowClobber - 第二步:安装目标命令所属的
Az.OperationalInsights模块Install-Module -Name Az.OperationalInsights -Force -AllowClobber - 第三步:手动导入模块确认加载无异常
Import-Module Az.OperationalInsights - 第四步:验证命令是否可以正常识别
Get-Command Invoke-AzOperationalInsightsQuery
执行后如果返回命令的基本信息,说明问题已修复,可以正常使用该命令。
常见异常处理
- 安装模块时提示不受信任的存储库,输入
A选择同意所有操作即可继续安装 - 国内Azure云用户使用命令前,需要先运行
Connect-AzAccount -Environment AzureChinaCloud完成账号认证
内容的提问来源于stack exchange,提问作者Ethan
相关产品推荐
相关产品推荐

