无法使用Powershell脚本启动Azure VM.我们得到无法使用指定的命名参数来解析参数集 [英] Unable to Start an Azure VM using Powershell script. We get Parameter set cannot be resolved using the specified named parameters

查看:276
本文介绍了无法使用Powershell脚本启动Azure VM.我们得到无法使用指定的命名参数来解析参数集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们使用powershell脚本通过构建作业来启动和停止VM.请在下面查看构建作业的屏幕截图

We use powershell script to start and stop the VMs using the build job. Please see the screenshot of the build job below

这是启动VM的简单Powershell脚本.问题是,当此作业运行时,我们遇到错误,构建失败. 我们得到无法使用指定的命名参数来解析参数集

It is a simple powershell script to start an VM. The issue is when this job runs, we are getting an error and the build fails. We get Parameter set cannot be resolved using the specified named parameters

但是,当我们使用Powershell控制台在本地运行它时,VM便开始了.

But when we run it locally using the powershell console, the VMs get started.

请在下面找到错误屏幕截图

Please find the error screenshot below

我在这里错过了什么吗.任何帮助将不胜感激.

Am I missing something here.. Any help would be very much appreciated.

编辑1 Powershell脚本

EDIT 1 Powershell script

$machines = @("machinename")
Select-AzureSubscription -Default "XXXYYYZZZ"

Foreach ($machine in $machines)
{   
Try
{
    Start-AzureVM -ServiceName $machine -Name $machine
}
Catch
{
}
}

推荐答案

我检查了屏幕截图,发现您想停止经典VM.但是,您使用cmdlet Add-AzureRmAccount登录Azure并使用cmdlet select-azurermsubscription选择订阅,对吗?这两个cmdlet是ARM模式cmdlet,应使用经典模式cmdlet.

I check your screenshot, I find you want to stop classic VMs. However, you logon Azure with cmdlet Add-AzureRmAccount and select subscription with cmdlet select-azurermsubscription, am I right? The two cmdlets are ARM mode cmdlets, you should use classic mode cmdlets.

Add-AzureAccount

根据您的错误,您不能使用Select-AzureSubscription -Default "XXXYYYZZZ". Default无法添加参数.有关更多信息,请参阅此

According to your error, you could not use Select-AzureSubscription -Default "XXXYYYZZZ". Default could not add parameters. More information please refer to this link.

尝试使用以下cmdlet.

Try to use the following cmdlets.

Get-AzureSubscription

Select-AzureSubscription -SubscriptionName <YourSubscriptionName> -Default

这篇关于无法使用Powershell脚本启动Azure VM.我们得到无法使用指定的命名参数来解析参数集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆