Skip to content

Instantly share code, notes, and snippets.

@andreaswasita
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andreaswasita/84bb3133bc7b915bc352 to your computer and use it in GitHub Desktop.
Save andreaswasita/84bb3133bc7b915bc352 to your computer and use it in GitHub Desktop.
cls
Import-module Azure
$subscription = Read-Host -Prompt 'Microsoft Azure Subscription:'
$storage = Read-Host -Prompt 'Storage Account Name:'
Set-azuresubscription -SubscriptionName $subscription -CurrentStorageAccountName $storage
#Get the latest image ; Windows Server 2012 Datacenter or mykloud2012datacenterimage
$images = Get-AzureVMImage `
| where { $_.Label -like "Windows Server 2012 Datacenter" } `
| Sort-Object -Descending -Property PublishedDate
$latestImage = $images[0]
$latestImage
#image
$myimage = Read-Host -Prompt 'Azure Image Name:'
#cloudservice
$service = Read-Host -Prompt 'Azure Service Name:'
#vmname
$name = Read-Host -Prompt 'Azure VM Name:'
#instance size: ExtraSmall, Small, Medium, Large, ExtraLarge, A5, A6, A7, A8, A9
$instance = Read-Host -Prompt 'Instance Size:'
#admin
$username = Read-Host -Prompt 'Admin User Name:'
#password
$password = Read-Host -Prompt 'Password:'
#location
$location = Read-Host -Prompt 'Azure Location:'
#vm configuration
$myVM = New-AzureVMConfig -Name $name -InstanceSize $instance -ImageName $myimage -DiskLabel "OS" `
| Add-AzureProvisioningConfig -Windows -Password $password -AdminUsername $username -DisableAutomaticUpdates
#createVM
New-AzureVM -ServiceName $service -VMs $myVM -Location $location
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment