Forum Discussion
美奈 堀内
Nov 28, 2017Copper Contributor
Azure Automation Script
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
Sort By
- David DelorgeCopper ContributorHere 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
- Isaac ObenCopper Contributor
Look into this to see if that is what you need
https://docs.microsoft.com/en-us/azure/automation/automation-solution-vm-management
- 美奈 堀内Copper ContributorHello 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