I am trying to display the PowerShell data in the following format.
Vnet Subnet
---- ------
AZRWUSVNET1 default
Corpvnet MgmtSubnet
Corpvnet Devsubnet
Corpvnet QASubnet
Corpvnet ProdSubnet
I have tried this below script
$a = Get-AzVirtualNetwork
$b = $a | Select-Object Name,Subnets
$ResourceList = @()
foreach ($item in $b)
{
$vnetname = ($b | Where-Object -Property Name -EQ ($item.Name))
$subnet = $vnetname.Subnets.Name
$vnetname = $item.Name
$VMObject = New-Object PSObject
$VMObject | Add-Member -MemberType NoteProperty -Name "Vnet" -Value $vnetname
$VMObject | Add-Member -MemberType NoteProperty -Name "Subnet" -Value $subnet
$ResourceList += $VMObject
}
$ResourceList
But I am getting the data in the following format
Vnet Subnet
---- ------
AZRWUSVNET1 default
Corpvnet {MgmtSubnet, Devsubnet, QASubnet, ProdSubnet…}
Can anyone please help here.
question from:https://stackoverflow.com/questions/65938349/displaying-the-content-of-subnet-in-a-form-of-table-in-powershell