这个post正是我所需要的,但我想添加NSG和路由表信息:
$subs = Get-AzSubscription
foreach ($Sub in $Subs) {
Write-Host "***************************"
Write-Host " "
$Sub.Name
$SelectSub = Select-AzSubscription -SubscriptionName $Sub.Name
$VNETs = Get-AzVirtualNetwork
foreach ($VNET in $VNETs) {
Write-Host "--------------------------"
Write-Host " "
Write-Host " vNet: " $VNET.Name
Write-Host " AddressPrefixes: " ($VNET).AddressSpace.AddressPrefixes
$vNetExpanded = Get-AzVirtualNetwork -Name $VNET.Name -ResourceGroupName $VNET.ResourceGroupName -ExpandResource 'subnets/ipConfigurations'
foreach($subnet in $vNetExpanded.Subnets)
{
Write-Host " Subnet: " $subnet.Name
Write-Host " Connected devices " $subnet.IpConfigurations.Count
foreach($ipConfig in $subnet.IpConfigurations)
{
Write-Host " " $ipConfig.PrivateIpAddress
}
}
Write-Host " "
}
}
我试着添加变量来反映它,但我想我不能让它工作。
1条答案
按热度按时间0vvn1miw1#
添加以下脚本片段以获取NetworkSecurityGroup(NSG)和路由表信息:
输出: