Skip to content

Instantly share code, notes, and snippets.



Last active Aug 29, 2015
What would you like to do?
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]
$myimage = Read-Host -Prompt 'Azure Image Name:'
$service = Read-Host -Prompt 'Azure Service Name:'
$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:'
$username = Read-Host -Prompt 'Admin User Name:'
$password = Read-Host -Prompt 'Password:'
$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
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