vm script
vm script
$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