Posts

Showing posts from July, 2020

Find the Vnet details of an Azure VM -Powershell

FInd the azure powershell script to get the VNET of an azure VM  Import-Module -Name Az  Login-AzAccount $vmname=Read-host "Enter the name of your VM"  $vmName=Get-AzVM -Name $vmname $VM = Get-azVM -ResourceGroupName $vmName.ResourceGroupName -Name $VMName.name  $VMNicName = $vmname.NetworkProfile.NetworkInterfaces.Id.Split("/")[-1]  $VMNic=Get-AzNetworkInterface -ResourceGroupName $RG -name $VMNicName  $VMvNetName = $VMNic.IpConfigurations.Subnet.Id.Split("/")[8]  $vNet = Get-AzVirtualNetwork  -ResourceGroupName $RG -Name $VMvNetName Write-host "Vnet of the VM is : " $vNet.Name