GET-IT: TEAMS DAY | 1-Day Free Virtual Conference all about Teams. Here on Petri.com - 8/12/20 GET-IT: TEAMS DAY - 8/12/20

Schedule shutdown doesnt recognize default subscription name

Home Forums Cloud Computing Microsoft Azure Schedule shutdown doesnt recognize default subscription name

Viewing 1 post (of 1 total)
  • Author
    Posts
  • Avatar
    5habbaranks
    Member
    #166222

    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:

    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 to
    set the default subscription.
    At stop-vm-server:5 char:5
    +
    + CategoryInfo : CloseError: (:) [Get-AzureVM], ApplicationException
    + FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.ServiceManagement.IaaS.GetAzureVMCommand[/CODE]

    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)
    {   
    $VMName = $VM.Name
      Write-Output “Attempting to shut down VM: $VMName”
      Stop-AzureVM -ServiceName $VM.ServiceName -Name $VM.Name
    }
    }
    }[/CODE][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 to
    set the default subscription.
    At stop-vm-server:5 char:5
    +
    + CategoryInfo : CloseError: (:) [Get-AzureVM], ApplicationException
    + FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.ServiceManagement.IaaS.GetAzureVMCommand[/CODE]

    The Code I’m using is

    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)
    {   
    $VMName = $VM.Name
      Write-Output “Attempting to shut down VM: $VMName”
      Stop-AzureVM -ServiceName $VM.ServiceName -Name $VM.Name
    }
    }
    }[/CODE][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)
    {   
    $VMName = $VM.Name
      Write-Output “Attempting to shut down VM: $VMName”
      Stop-AzureVM -ServiceName $VM.ServiceName -Name $VM.Name
    }
    }
    }[/CODE]

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.