0
votes

I'm trying to start an Azure VM using the following PowerShell script:

$subscriptionId = "00000000-0000-0000-0000-000000000000"
$azureVM = "VS2017"
$resourceGroup = "VS2017ResourceGroup"
Add-AzureRmAccount # here start interactive login
Select-AzureSubscription -SubscriptionId $subscriptionId
Start-AzureRmVM - -ResourceGroupName $resourceGroup -Name $azureVM

When executing the script, I receive the following response:

Start-AzureRmVM : A positional parameter cannot be found that accepts argument '-'.
At C:\Users\ralbano\Desktop\Senza nome7.ps1:11 char:1
+ Start-AzureRmVM - -ResourceGroupName "VS2017ResourceGroup" -Name $azu ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Start-AzureRmVM], ParameterBindingException
    + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.Azure.Commands.Compute.StartAzureVMCommand

I am using Windows PowerShell ISE to run the script.

Am I doing something wrong?

I checked the subscription id and the resource group name and are correct (of course in the sample above the subscription id is a fake). The VM is in "Stopped (deallocated)" state on Azure.

1
Is the VM a classic VM or an ARM VM? Have to tried Start-AzureRmVM?Gaurav Mantri
It is NOT a classic VM.dancerjude
I tried using Start-AzureRmVM, but of course I am changing the Add-AzureAccount to Add-AzureRmAccount and now the problem is on this Add :-(dancerjude
Please try Start-AzureRmVM (docs.microsoft.com/en-us/powershell/module/azurerm.compute/…). I believe Start-AzureVM is for starting Classic VMs.Gaurav Mantri
What's the problem you're getting with Add? Please edit the question and include this information there?Gaurav Mantri

1 Answers

0
votes

Start-AzureRmVM - -ResourceGroupName $resourceGroup -Name $azureVM

According to your error message, we should use this command like this:

Start-AzureRmVM -ResourceGroupName $resourceGroup -Name $azureVM