Last active
April 16, 2017 13:02
-
-
Save rajcheval/2947400bcc7d1b234b58615d299c0092 to your computer and use it in GitHub Desktop.
This script gets the private IP addresses for each Azure Virtual Machine in a Virtual Machine Scaleset
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.SYNOPSIS | |
The script get the private IP addresses for each Vm in a virtual machine scale set. | |
.DESCRIPTION | |
The script get the private IP addresses for each Vm in a virtual machine scale set. | |
This is the resource group name for VMSS. | |
.PARAMETER ResourceGroupName | |
This is the name of the VMSS | |
.PARAMETER VMSSName | |
.EXAMPLE | |
.\getvmssipaddresses.ps1 -ResourceGroupName rgname -VMSSName vmssname | |
#> | |
[CmdletBinding()] | |
param( | |
[Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Position=1)] | |
[String] $ResourceGroupName, | |
[Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Position=2)] | |
[String] $VMSSName | |
) | |
#Get Nics associated with the VMSS | |
$nics = Get-AzureRmResource -ResourceGroupName $ResourceGroupName -ResourceType Microsoft.Compute/virtualMachineScaleSets/networkInterfaces -ResourceName $VMSSName -ApiVersion 2016-09-01 | |
foreach( $nic in $nics) | |
{ | |
Write-Host $nic[0].properties.ipConfigurations[0].properties.privateIPAddress | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment