We use powershell script to start and stop the VMs using the build job. Please see the screenshot of the build job below
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
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
{
}
}
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