小编SRo*_*Roy的帖子

在模块“Az.Compute”中找到“Get-azVM”命令,但无法加载该模块

我在 powershell 脚本中使用了 Az 模块,该脚本从 powershell core 执行,但在从应用程序(.Net core SDK 2.1)执行脚本时出现错误。

$VMExistanceCheck = Get-azVM -ResourceGroupName $VMResourceGroup -Name $NewComputerName -ErrorAction SilentlyContinue

我检查了 Az.Compute 模块已导入那里。

Import-Module Az.compute -verbose -force也在脚本中添加了。

使用 runspace(System.Management.Automation, Version=6.1.0.0) 从应用程序调用脚本时出现以下错误:

System.Management.Automation.RuntimeException:在模块“Az.Compute”中找到“Get-azVM”命令,但无法加载该模块。有关详细信息,请运行“导入模块 Az.Compute”。---> System.Management.Automation.CommandNotFoundException:在模块“Az.Compute”中找到“Get-azVM”命令,但无法加载该模块。有关详细信息,请运行“导入模块 Az.Compute”。

“Get-Module -ListAvailable ”显示 Az.Compute 模块可用,但使用 Powershell 6 执行“import-module Az.Compute”命令时,没有导入任何内容。

powershell azure-powershell az

5
推荐指数
2
解决办法
2万
查看次数

标签 统计

az ×1

azure-powershell ×1

powershell ×1