0% found this document useful (0 votes)
51 views2 pages

VM Creation:: - Select Ipaddress

Is contains the contents regarding Azure power shell concepts. It's useful for power shell beginners

Uploaded by

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

VM Creation:: - Select Ipaddress

Is contains the contents regarding Azure power shell concepts. It's useful for power shell beginners

Uploaded by

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

Vm Creation:

1. Connect-AzureRmAccount​ : To enter into azure portal, give ur credentials


2. New-AzureRmVM -ResourceGroupName "RG_AZR_Sireesha" -Name "myVM" -Location "East US"
-VirtualNetworkName "vnet1" -SubnetName "subnet1" -PublicIpAddressName "mypublicIp"
3. Next it will prompt to enter username and password for Vm, give them.
Succesfully created Vm.

Get ip address of all vms in resource group:


Get-AzureRmPublicIpAddress​ -ResourceGroupName​ ​"myResourceGroupVM"​ | Select IpAddress

To get vm details:
Get-AzureRmVm ​-ResourceGroupName​ ​"myResourceGroup" -Name “myVm”

To get vm ip Address:
Get-AzureRmPublicIpAddress -ResourceGroupName "RG_AZR_Sireesha" -Name mypublicIp | Select
IpAddress
Here​ ​mypublicIp​ : ipaddress name given while creating vm

(or)
$vm=Get-AzureRmVM -Name "myVM" -ResourceGroupName RG_AZR_Sireesha | select
-ExpandProperty networkprofile | select -ExpandProperty networkinterfaces | select -ExcludeProperty
id

$NIC=$vm.Id.Split('/') | select -Last 1

$NIC=Get-AzureRmNetworkInterface -Name $NIC -ResourceGroupName RG_AZR_Sireesha

$nic=$NIC.IpConfigurations | select -ExpandProperty PublicIpAddress | select -ExpandProperty Id


$nic=$nic.Split('/') | select -Last 1

Get-AzureRmPublicIpAddress -Name $nic -ResourceGroupName RG_AZR_Sireesha | select


-ExpandProperty Ipaddress

Connect to Vm:
mstsc /v:<publicIpAddress>
Mstsc /v:40.76.202.208

Adding Multiple Nic cards to existing Vm:

1) Deallocate the VM with​ ​Stop-AzureRmVM​. The following example deallocates the VM


named
Stop-AzureRmVM -Name "myVM" -ResourceGroupName "myResourceGroup"
2) Get the existing configuration of the VM with​ ​Get-AzureRmVm​.
$vm = Get-AzureRmVm -Name "myVM" -ResourceGroupName "myResourceGroup"

3) Create ​NIC .For creating NIC we want subnet Id .for SubnetId we have to go to Vnet
#​ Get info for the back end subnet:

$myVnet = Get-AzureRmVirtualNetwork -Name "myVnet" -ResourceGroupName


"myResourceGroup"
$backEnd = $myVnet.Subnets| where Name -Eq “subnet1” | select Id

# Create a virtual NIC


$myNic3 = New-AzureRmNetworkInterface -ResourceGroupName "myResourceGroup" `
-Name "myNic3" `
-Location "EastUs" `
-SubnetId $backEnd

# Get the ID of the new virtual NIC and add to VM


$nicId = (Get-AzureRmNetworkInterface -ResourceGroupName "myResourceGroup" -Name
"MyNic3").Id
Add-AzureRmVMNetworkInterface -VM $vm -Id $nicId | Update-AzureRmVm
-ResourceGroupName "myResourceGroup"

If one of the Nic sets as Primary then you change by using this cmnd

# List existing NICs on the VM and find which one is primary


$vm.NetworkProfile.NetworkInterfaces

# Set NIC 0 to be primary


$vm.NetworkProfile.NetworkInterfaces[0].Primary = $true
$vm.NetworkProfile.NetworkInterfaces[1].Primary = $false

# Update the VM state in Azure


Update-AzureRmVM -VM $vm -ResourceGroupName "myResourceGroup"
https://docs.microsoft.com/en-us/azure/virtual-machines/windows/multiple-nics

You might also like