Skip to content

Instantly share code, notes, and snippets.

@rajcheval
Last active April 16, 2017 13:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rajcheval/2947400bcc7d1b234b58615d299c0092 to your computer and use it in GitHub Desktop.
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
<#
.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