forked from adminph-de/Azure
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Untitled3.ps1
25 lines (18 loc) · 986 Bytes
/
Untitled3.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#Create the VM
$vnetName = 'ams-vnet-1'
$vnetResourceGroupe = 'ams-core-network'
$nicName = 'ams-k2-rdp01-p_nic0'
$vmName = "ams-k2-rdp01-p"
$vmSize = "Standard_A2"
$SingleSubnet = Get-AzureRmVirtualNetwork -ResourceGroupName $vnetResourceGroupe -Name $vnetName | Get-AzureRmVirtualNetworkSubnetConfig
$vnet = Get-AzureRmVirtualNetwork -name $vnetName -ResourceGroupName $vnetResourceGroupe
$nic = New-AzureRmNetworkInterface -Name $nicName `
-ResourceGroupName $destinationResourceGroup `
-Location $location -SubnetId $vnet.Subnets[4].Id `
-PublicIpAddressId $pip.Id `
-NetworkSecurityGroupId $nsg.Id
$vmConfig = New-AzureRmVMConfig -VMName $vmName -VMSize $vmSize
$vm = Add-AzureRmVMNetworkInterface -VM $vmConfig -Id $nic.Id
$vm = Set-AzureRmVMOSDisk -VM $vm -ManagedDiskId $osDisk.Id -StorageAccountType Standard_LRS `
-DiskSizeInGB 128 -CreateOption Attach -Windows
New-AzureRmVM -ResourceGroupName $destinationResourceGroup -Location $location -VM $vm