- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to get the load balancers connected to the Azure VM using PowerShell?
To get the load balancers attached to the Azure VM using PowerShell, we first need to retrieve the Azure VM network settings. For example, we have an Azure VM name “TestVM” and we will
PS C:\> $vm = Get-AzVM -Name TestVM $nic = (($vm.NetworkProfile.NetworkInterfaces.id).Split('/'))[-1]
Once we have the network interface name, we need to retrieve the load balancer settings, and to get the Load Balancer settings we need to use the Get-AzNetworkInterface command.
PS C:\> $nicsettings = Get-AzNetworkInterface -Name $nic
The below command will retrieve the load balancer name.
(($nicsettings.IpConfigurations.LoadBalancerBackendAddressPools.id).Split('/'))[-3]
To get the Load Balancer backend pool name, use the below command.
(($nicsettings.IpConfigurations.LoadBalancerBackendAddressPools.id).Split('/'))[-1]
Overall Script −
$vm = Get-AzVM -Name ‘TestVM’ $vmnic = ($vm.NetworkProfile.NetworkInterfaces.id).Split('/')[-1] $nicsettings = Get-AzNetworkInterface -Name $vmnic Write-Output "Load Balancer: : $((($nicsettings.IpConfigurations.LoadBalancerBackendAddressPools.id).Split('/'))[-3])" Write-Output "Backend Pool: $((($nicsettings.IpConfigurations.LoadBalancerBackendAddressPools.id).Split('/'))[-1])"
Advertisements