Azure Automation Script

%3CLINGO-SUB%20id%3D%22lingo-sub-131752%22%20slang%3D%22en-US%22%3EAzure%20Automation%20Script%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-131752%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20there%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20would%20like%20to%20start%20my%20machines%20by%20automation.%3C%2FP%3E%0A%3CP%3EI%20used%20to%20success%20to%20start%20and%20stop%20by%20powershell%20workflow%20script.%20but%20it%20was%20for%20the%20machine%20that%20deployed%20Classic.%26nbsp%3B%3C%2FP%3E%0A%3CP%3ENow%20i%20would%20like%20to%20write%20the%20script%20for%20the%20machines%20that%20be%20deployed%20Resource%20Manager.%3C%2FP%3E%0A%3CP%3EI%20can%20find%20a%20lot%20of%20scripts%20but%20all%20fail%20on%20my%20environment.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIt%20would%20very%20happy%20if%20someone%20show%20me%20the%20script%20of%20just%20start%20the%20machine.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EBest%20Regards%2C%3C%2FP%3E%0A%3CP%3EMina%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-131752%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-133300%22%20slang%3D%22en-US%22%3ERE%3A%20Azure%20Automation%20Script%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-133300%22%20slang%3D%22en-US%22%3EHere%20is%20a%20simple%20Script%20that%20works%20in%20ARM%3A%20%23%23Login%20to%20Azure%20ARM%20%23%23This%20script%20gathers%20information%20about%20Azure%20ARM%20REsources%20%24azureAccountName%20%3D%22youraccount%40yourdns.onmicrosoft.com%22%20%24azurePassword%20%3D%20ConvertTo-SecureString%20%22xxxxx%22%20-AsPlainText%20-Force%20%24psCred%20%3D%20New-Object%20System.Management.Automation.PSCredential(%24azureAccountName%2C%20%24azurePassword)%20Add-AzureRmAccount%20-Credential%20%24psCred%20%23%23Switch%20Subscriptions%20and%20set%20subscriptions%20Set-AzureRmContext%20-SubscriptionName%20%22Microsoft%20Azure%22%20Start-AzureRMVM%20-ResourceGroupName%20d-ehm-dev-na-01-rg%20-name%20AUSEDEVADDCS01%20Start-AzureRMVM%20-ResourceGroupName%20d-ehm-dev-na-01-rg%20-name%20AUSEDEVJMPBX01%20Start-AzureRMVM%20-ResourceGroupName%20d-ehm-dev-na-01-rg%20-name%20AUSEDEVWNS1201%20Here%20is%20the%20STOP%20%23%23Login%20to%20Azure%20ARM%20%23%23This%20script%20gathers%20information%20about%20Azure%20ARM%20REsources%20%24azureAccountName%20%3D%22youraccount%40yourdns.onmicrosoft.com%22%20%24azurePassword%20%3D%20ConvertTo-SecureString%20%22xxxxx%22%20-AsPlainText%20-Force%20%24psCred%20%3D%20New-Object%20System.Management.Automation.PSCredential(%24azureAccountName%2C%20%24azurePassword)%20Add-AzureRmAccount%20-Credential%20%24psCred%20%23%23Switch%20Subscriptions%20and%20set%20subscriptions%20Set-AzureRmContext%20-SubscriptionName%20%22Microsoft%20Azure%22%20Stop-AzureRMVM%20-ResourceGroupName%20d-ehm-dev-na-01-rg%20-name%20AUSEDEVADDCS01%20-force%20Stop-AzureRMVM%20-ResourceGroupName%20d-ehm-dev-na-01-rg%20-name%20AUSEDEVJMPBX01%20-force%20Stop-AzureRMVM%20-ResourceGroupName%20d-ehm-dev-na-01-rg%20-name%20AUSEDEVWNS1201%20-force%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-133075%22%20slang%3D%22en-US%22%3ERe%3A%20Azure%20Automation%20Script%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-133075%22%20slang%3D%22en-US%22%3EHello%20Isaac%2C%3CBR%20%2F%3E%3CBR%20%2F%3EThanks%20for%20your%20comment!%20I%20read%20the%20url%20that%20you%20gave%20me.%20i%20was%20thinking%20i%20have%20to%20write%20the%20scripts%20for%20start%2Fstop%20the%20machine%20automatically.%20The%20url%20looks%20like%20i%20can%20set%20it%20without%20write%20the%20script%20myself%20%3Ao%3C%2Fimg%3E%20I%20will%20try%20the%20steps%20on%20my%20environment.%20Please%20let%20me%20ask%20you%20if%20i%20stuck%20while%20this%20challenge.%3CBR%20%2F%3E%3CBR%20%2F%3EBest%20Regards%2C%3CBR%20%2F%3EMina%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-133049%22%20slang%3D%22en-US%22%3ERe%3A%20Azure%20Automation%20Script%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-133049%22%20slang%3D%22en-US%22%3E%3CP%3ELook%20into%20this%20to%20see%20if%20that%20is%20what%20you%20need%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fautomation%2Fautomation-solution-vm-management%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fautomation%2Fautomation-solution-vm-management%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

Hi there,

 

I would like to start my machines by automation.

I used to success to start and stop by powershell workflow script. but it was for the machine that deployed Classic. 

Now i would like to write the script for the machines that be deployed Resource Manager.

I can find a lot of scripts but all fail on my environment.

 

It would very happy if someone show me the script of just start the machine.

 

Best Regards,

Mina

3 Replies
Hello Isaac,

Thanks for your comment! I read the url that you gave me. i was thinking i have to write the scripts for start/stop the machine automatically. The url looks like i can set it without write the script myself :o I will try the steps on my environment. Please let me ask you if i stuck while this challenge.

Best Regards,
Mina
Here is a simple Script that works in ARM: ##Login to Azure ARM ##This script gathers information about Azure ARM REsources $azureAccountName ="youraccount@yourdns.onmicrosoft.com" $azurePassword = ConvertTo-SecureString "xxxxx" -AsPlainText -Force $psCred = New-Object System.Management.Automation.PSCredential($azureAccountName, $azurePassword) Add-AzureRmAccount -Credential $psCred ##Switch Subscriptions and set subscriptions Set-AzureRmContext -SubscriptionName "Microsoft Azure" Start-AzureRMVM -ResourceGroupName d-ehm-dev-na-01-rg -name AUSEDEVADDCS01 Start-AzureRMVM -ResourceGroupName d-ehm-dev-na-01-rg -name AUSEDEVJMPBX01 Start-AzureRMVM -ResourceGroupName d-ehm-dev-na-01-rg -name AUSEDEVWNS1201 Here is the STOP ##Login to Azure ARM ##This script gathers information about Azure ARM REsources $azureAccountName ="youraccount@yourdns.onmicrosoft.com" $azurePassword = ConvertTo-SecureString "xxxxx" -AsPlainText -Force $psCred = New-Object System.Management.Automation.PSCredential($azureAccountName, $azurePassword) Add-AzureRmAccount -Credential $psCred ##Switch Subscriptions and set subscriptions Set-AzureRmContext -SubscriptionName "Microsoft Azure" Stop-AzureRMVM -ResourceGroupName d-ehm-dev-na-01-rg -name AUSEDEVADDCS01 -force Stop-AzureRMVM -ResourceGroupName d-ehm-dev-na-01-rg -name AUSEDEVJMPBX01 -force Stop-AzureRMVM -ResourceGroupName d-ehm-dev-na-01-rg -name AUSEDEVWNS1201 -force