0% found this document useful (0 votes)
18 views

vm script

Uploaded by

rashaidbin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

vm script

Uploaded by

rashaidbin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

$stName = "sun01sa"

$locName = "westeurope"
$rgName = "RSG-PRO2"
New-AzureRmResourceGroup -Name $rgName -Location $locName
$storageAcc = New-AzureRmStorageAccount -ResourceGroupName $rgName -Name $stName -
Type "Standard_GRS" -Location $locName
$singleSubnet = New-AzureRmVirtualNetworkSubnetConfig -Name Subnet-2 -AddressPrefix
192.168.0.0/24
$vnet = New-AzureRmVirtualNetwork -Name VNET-2 -ResourceGroupName $rgName -Location
$locName -AddressPrefix 192.168.0.0/24 -Subnet $singleSubnet
$pip = New-AzureRmPublicIpAddress -Name VM2PIP -ResourceGroupName $rgName -Location
$locName -AllocationMethod Dynamic
$nic = New-AzureRmNetworkInterface -Name VM2NIC -ResourceGroupName $rgName -
Location $locName -SubnetId $vnet.Subnets[0].Id -PublicIpAddressId $pip.Id
$cred = Get-Credential -Message "Type the name and password of the
localadministrator account."
$vm = New-AzureRmVMConfig -VMName WindowsVM-2 -VMSize "Standard_b1ls"
$vm = Set-AzureRmVMOperatingSystem -VM $vm -Windows -ComputerName VM-2 -Credential
$cred -ProvisionVMAgent -EnableAutoUpdate
$vm = Set-AzureRmVMSourceImage -VM $vm -PublisherName MicrosoftWindowsServer -Offer
WindowsServer -Skus 2012-R2-Datacenter -Version "latest"
$vm = Add-AzureRmVMNetworkInterface -VM $vm -Id $nic.Id
$osDiskUri = $storageAcc.PrimaryEndpoints.Blob.ToString()
+"vhds/WindowsVMosDisk.vhd"
$vm = Set-AzureRmVMOSDisk -VM $vm -Name "windowsvmosdisk" -VhdUri $osDiskUri -
CreateOption fromImage
New-AzureRmVM -ResourceGroupName $rgName -Location $locName -VM $vm

You might also like