Another VM Creation Powershell Script (untested)

Tags: azure, powershell, image creation

Example 1
I need a PowerShell command set to create the initial virtual machine for an Active Directory domain controller that:
•Uses the Windows Server 2012 R2 Datacenter image.
•Has the name AZDC1.
•Is a standalone computer.
•Has an additional data disk of 20 GB.
•Has the static IP address 192.168.244.4.
•Is in the BackEnd subnet of the AZDatacenter virtual network.
•Is in the Azure-TailspinToys cloud service.
 
Here is the corresponding Azure PowerShell command set to create this virtual machine, with blank lines between each block for readability.

 
$family="Windows Server 2012 R2 Datacenter"
$image=Get-AzureVMImage | where { $_.ImageFamily -eq $family } | sort PublishedDate -Descending | select -ExpandProperty ImageName -First 1
$vmname="AZDC1"
$vmsize="Medium"
$vm1=New-AzureVMConfig -Name $vmname -InstanceSize $vmsize -ImageName $image

$cred=Get-Credential -Message "Type the name and password of the local administrator account."
$vm1 | Add-AzureProvisioningConfig -Windows -AdminUsername $cred.Username -Password $cred.GetNetworkCredential().Password

$vm1 | Set-AzureSubnet -SubnetNames "BackEnd"

$vm1 | Set-AzureStaticVNetIP -IPAddress 192.168.244.4

$disksize=20
$disklabel="DCData"
$lun=0
$hcaching="None"
$vm1 | Add-AzureDataDisk -CreateNew -DiskSizeInGB $disksize -DiskLabel $disklabel -LUN $lun -HostCaching $hcaching

$svcname="Azure-TailspinToys"
$vnetname="AZDatacenter"
New-AzureVM –ServiceName $svcname -VMs $vm1 -VNetName $vnetname

No Comments

You must log on to comment.