Announcement

Collapse
No announcement yet.

Schedule shutdown doesnt recognize default subscription name

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Schedule shutdown doesnt recognize default subscription name

    Hi,

    I'm looking at the guide to shutting down VM's within an Azure network the subscription name is Pay-As-You-Go but when I run the script it errors as below:

    Code:
    06/03/2016 21:26:50, Error: Add-AzureAccount : Cannot bind argument to parameter 'Credential' because it is null.
    At stop-vm-server:4 char:4
    +
        + CategoryInfo          : InvalidData: (:) [Add-AzureAccount], ParameterBindingValidationException
        + FullyQualifiedErrorId :
    ParameterArgumentValidationErrorNullNotAllowed,Microsoft.WindowsAzure.Commands.Profile.AddAzureAccount
     
    06/03/2016 21:26:50, Error: Select-AzureSubscription : Parameter set cannot be resolved using the specified named parameters.
    At stop-vm-server:5 char:5
    +
        + CategoryInfo          : InvalidArgument: (:) [Select-AzureSubscription], ParameterBindingException
        + FullyQualifiedErrorId :
    AmbiguousParameterSet,Microsoft.WindowsAzure.Commands.Profile.SelectAzureSubscriptionCommand
     
    06/03/2016 21:26:50, Error: Get-AzureVM : No default subscription has been designated. Use Select-AzureSubscription -Default <subscriptionName> to
    set the default subscription.
    At stop-vm-server:5 char:5
    +
        + CategoryInfo          : CloseError: (:) [Get-AzureVM], ApplicationException
        + FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.ServiceManagement.IaaS.GetAzureVMCommand
    The Code I'm using is

    Code:
    workflow stop-vm-server
    {
    $Cred = Get-AutomationPSCredential -Name '[email protected]'
    Add-AzureAccount -Credential $Cred
    InlineScript
      {
      Select-AzureSubscription -Default "Pay-As-You-Go"
      $VMS = Get-AzureVM
      ForEach ($VM in $VMS)
        {&nbsp;&nbsp;&nbsp;
        $VMName = $VM.Name
    &nbsp;   Write-Output "Attempting to shut down VM: $VMName"
      &nbsp;&nbsp;Stop-AzureVM -ServiceName $VM.ServiceName -Name $VM.Name
        }
      }
    }

  • #2
    This is your issue. Check the credentials are being passed to the command.
    Error: Add-AzureAccount : Cannot bind argument to parameter 'Credential' because it is null.

    Comment


    • #3
      Thanks - just to check this is the account within the automation accounts section then assets? As the account is the one I specified within the powershell script. Thanks

      Comment


      • #4
        I have no idea. Thats something you will need to find out.

        Comment

        Working...
        X