【问题标题】:The term 'az' is not recognized from Run Command Script运行命令脚本无法识别术语“az”
【发布时间】:2021-10-18 11:19:02
【问题描述】:

我尝试运行“az version”的简单命令,该命令将使用运行命令脚本在 VM 上执行,但出现此错误:The term 'az' 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.

但是当我从 VM 运行此命令时,我将它与远程桌面连接连接它可以工作,并且我会获得包含所有详细信息的“az 版本”。 我还在 VM 中安装了 AZ 模块。

我应该怎么做才能从运行命令脚本中操作“az”命令?

【问题讨论】:

    标签: azure azure-vm


    【解决方案1】:

    术语“az”未被识别为 cmdlet、函数的名称, 脚本文件或可运行的程序。检查名称的拼写,或 如果包含路径,请验证路径是否正确并重试。

    根据错误消息,您似乎没有安装 az module 来运行 az version cmdlet。

    我应该怎么做才能从运行中操作“az”命令 命令脚本?

    您需要安装 Azure CLI 以从门户的运行命令脚本运行 az cmdlet。

    您可以使用以下 cmdlet 将 AzureCLI 安装在预装了 Az 模块的 Windows 机器上。

    $ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest -Uri https://aka.ms/installazurecliwindows -OutFile .\AzureCLI.msi; Start-Process msiexec.exe -Wait -ArgumentList '/I AzureCLI.msi /quiet'; rm .\AzureCLI.msi
    

    安装 Azure CLI 后,您可以运行 Az version cmdlet 来检查 Az cli 版本。

    【讨论】:

    • 我将这一行放在脚本的第一行,它就可以工作了!谢谢!
    • 很高兴我能提供帮助,您能否接受答案作为解决方案。这可以帮助将来有类似查询的其他社区用户。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-11-19
    • 1970-01-01
    • 2015-09-10
    • 1970-01-01
    • 2021-11-25
    • 1970-01-01
    • 2020-02-14
    相关资源
    最近更新 更多