Skip to content

Instantly share code, notes, and snippets.

@SQLtattoo
Created June 12, 2020 10:09
Embed
What would you like to do?
Get a list of Network Interface Cards attached on NSGs and ASGs
Get-AzNetworkInterface | Select Name, ResourceGroupName,`
@{Name="NSG";Expression = {$_.NetworkSecurityGroup.Id.tostring().substring($_.NetworkSecurityGroup.Id.tostring().lastindexof('/')+1)}},`
@{Name="ASG";Expression={$_.IpConfigurations.ApplicationSecurityGroups.Id.tostring().substring($_.IpConfigurations.ApplicationSecurityGroups.Id.tostring().lastindexof('/')+1)}}
# optional if you want to add the below line for exporting to file
# | Export-Csv "nsg and asg info.csv" -Delimiter ","
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment