我尝试运行“az version”的简单命令,该命令将使用运行命令脚本在虚拟机上执行,但出现此错误:术语“az”未被识别为 cmdlet 的名称、函数、脚本文件或可运行程序。检查名称的拼写,或者如果包含路径,请验证路径是否正确,然后重试。
但是当我从虚拟机运行此命令时,我将其与远程桌面连接连接,它可以工作,并且我获得包含所有详细信息的“az 版本”。 我还在虚拟机中安装了 AZ 模块。
为了从运行命令脚本中操作“az”命令,我应该做什么?
最佳答案
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.
根据错误消息,您似乎尚未安装 az 模块
来运行 az 版本
cmdlet。
What should I do in order to operate 'az' commands from the Run Command Script?
您需要安装 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 版本 cmdlet 来检查 Az cli 版本。
关于azure - 运行命令脚本无法识别术语 'az',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69615140/