1

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

enter image description here

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

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

Please find the error screenshot below

enter image description here

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

EDIT 1 Powershell script

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

Foreach ($machine in $machines)
{   
Try
{
    Start-AzureVM -ServiceName $machine -Name $machine
}
Catch
{
}
}
Timothy Rajan
  • 1,947
  • 8
  • 38
  • 62

1 Answers1

3

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

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

Try to use the following cmdlets.

Get-AzureSubscription

Select-AzureSubscription -SubscriptionName <YourSubscriptionName> -Default
Shui shengbao
  • 18,746
  • 3
  • 27
  • 45
  • This works perfect. You are correct Since these are classic machines, I shuold not use Rm cmdlets. Switching to Select-AzureSubscription did the trick. Thank you very much – Timothy Rajan Apr 11 '17 at 04:50