-
-
Save andreaswasita/a6ae3f9be96089339646 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cls | |
Import-module Azure | |
#Get your subscription and storage name | |
$subscription = Read-Host -Prompt 'Microsoft Azure Subscription:' | |
$storage = Read-Host -Prompt 'Storage Account Name:' | |
#Set your default subscription | |
Set-azuresubscription -SubscriptionName $subscription -CurrentStorageAccountName $storage | |
#Get the latest Windows Server 2012 Datacenter image | |
$images = Get-AzureVMImage ` | |
| where { $_.ImageFamily -eq “Windows Server 2012 Datacenter” } ` | |
| Sort-Object -Descending -Property PublishedDate | |
$latestImage = $images[0] | |
$latestImage | |
#Get Other Details | |
$myimage = Read-Host -Prompt 'Azure Image Name:' | |
$service = Read-Host -Prompt 'Azure Service Name:' | |
$name = Read-Host -Prompt 'Azure VM Name:' | |
$instance = Read-Host -Prompt 'Instance Size:' | |
$username = Read-Host -Prompt 'Admin User Name:' | |
$password = Read-Host -Prompt 'Password:' | |
$VIP = Read-Host -Prompt 'Reserved VIP Name:' | |
$location = Read-Host -Prompt 'Azure Location:' | |
$myVM = New-AzureVMConfig -Name $name -InstanceSize $instance -ImageName $myimage -DiskLabel "OS" ` | |
| Add-AzureProvisioningConfig -Windows -Password $password -AdminUsername $username -DisableAutomaticUpdates | |
#Provision the new VM | |
New-AzureVM -ServiceName $service -VMs $myVM -ReservedIPName $VIP -Location $location |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment