Skip to content

Instantly share code, notes, and snippets.

@andreaswasita andreaswasita/NewVM.ps1
Last active Aug 29, 2015

Embed
What would you like to do?
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
You can’t perform that action at this time.