Azure

Azure “GoUp and Goto Sleep” Maintenance Scripts


Azure “GoUp and Goto Sleep” Maintenance Scripts
azure1
Below two simple scripts to Startup & Shutdown Azure Virtual Machines; you can use these samples scripts with “Azure Scheduler Agent” to reduce costs using “pay for use” Azure subscriptions.
** STARTUP VM **
workflow startup-vm
{
$Cred = Get-AutomationPSCredential -Name ‘My Scheduler’
Add-AzureAccount -Credential $CredInlineScript
{

    Select-AzureSubscription -SubscriptionName “My Subscription Name”

$VMS = Get-AzureVM

    foreach($VM in $VMS)
{
$VMName = $VM.Name
Start-AzureVM -ServiceName $VM.ServiceName -Name $VM.Name
Write-Output “Shutting down VM :  $VMName ”
}
}
}
** SHUTDOWN VM **
workflow shutdown-vm
{
$Cred = Get-AutomationPSCredential -Name ‘My Scheduler’
Add-AzureAccount -Credential $CredInlineScript
{

    Select-AzureSubscription -SubscriptionName “My Subscription Name”

$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 ”
}
}
}
you are welcome !
Annunci

Categorie:Azure, Azure Scripts

Con tag:,

Rispondi

Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:

Logo WordPress.com

Stai commentando usando il tuo account WordPress.com. Chiudi sessione / Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione / Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione / Modifica )

Google+ photo

Stai commentando usando il tuo account Google+. Chiudi sessione / Modifica )

Connessione a %s...