Skip to content

Instantly share code, notes, and snippets.

@techbunny
Created December 23, 2014 23:21
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 techbunny/3900c85a1cbd53b8ee4c to your computer and use it in GitHub Desktop.
Save techbunny/3900c85a1cbd53b8ee4c to your computer and use it in GitHub Desktop.
The Imperfect Lab: Deploying VMs
# Set Your Subscription and Storage Account
Set-AzureSubscription -SubscriptionName "Visual Studio Ultimate with MSDN" -CurrentStorageAccount "imperfectstore"
# Set basic variables for your VM. In this case, this is the adminstrator name and password, as well as the name of the Windows Server 2012 R2 image available at the time of this exercise. You'll want to make sure to get the current name of whatever OS you want to install.
$un = "adminname"
$pwd = "secretpassword"
$image = "a699494373c04fc0bc8f2bb1389d6106__Windows-Server-2012-R2-201411.01-en.us-127GB.vhd"
# Pick up that VM image the full list with:
Get-AzureVMImage | Select ImageName
# Configure a few more variables using the New-AzureVMConfig. In this case, I'm settting the server name and instance size, pulling in the username and password variable I set with the lines above and specifying the pre-existing subnet I want to use.
$newVM = New-AzureVMConfig -Name "Server2" -InstanceSize "Small" -Image $image
| Add-AzureProvisioningConfig -Windows -AdminUserName $un -Password $pwd
| Set-AzureSubnet -SubnetNames "FirstSubnet"
# Finally, kick off the VM creation with one of the following options:
# Into an Existing Cloud Service:
New-AzureVM -VMs $newVM -ServiceName "imperfectcore"
# Into an New Cloud Service:
New-AzureVM -VMs $newVM -ServiceName "newcloudservice" -Location "West US" -VNetName "imperfectnet"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment