Skip to content

Instantly share code, notes, and snippets.

@SQLtattoo
Created June 12, 2020 10:09
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save SQLtattoo/0f0fc77631987fda45e0d129b88b152e to your computer and use it in GitHub Desktop.
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