Azure Automation: VM shutdown runbook not working on new VM -


i had delete , re-install vm due issue vm locking up. vm online, noticed shutdown automation not working. working fine before ran issue vm. below ps script runbook, returns following error:

correlation id: 72fa8e58-89f1-4612-bc43-1b05876c2bff timestamp: 2015-08-25 06:04:14z: remote server returned error: (401) unauthorized. @ shutdown:6 char:6 +  + categoryinfo          : closeerror: (:) [add-azureaccount], aadauthenticationfailedexception + fullyqualifiederrorid : microsoft.windowsazure.commands.profile.addazureaccount  8/24/2015 11:04:25 pm, error: get-azurevm : no default subscription has been designated.  use select-azuresubscription -default <subscriptionname> set default subscription. @ shutdown:8 char:8 +  + categoryinfo          : closeerror: (:) [get-azurevm], applicationexception + fullyqualifiederrorid : microsoft.windowsazure.commands.servicemanagement.iaas.getazurevmcommand 

any idea missing working new vm? have been wracking brain credentials not include new vm, have come empty handed.

workflow shutdown {     $cred = get-automationpscredential -name "auto"      add-azureaccount -credential $cred       $vms = get-azurevm       foreach($vm in $vms)     {             $vmname = $vm.name          stop-azurevm -servicename $vm.servicename -name $vm.name -force         write-output "shutting down vm :  $vmname "     } }  

i think should add subscription name (select-azuresubscription in error log) in script using. there quite examples of doing in various ways in technet script libraries 1 https://gallery.technet.microsoft.com/scriptcenter/stop-azure-vm-with-orgid-41a79d91


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -