Hi Sufiyan Shaikh,
Thank you for posting your query in Microsoft QnA !
You can use below script to get all the Subnet details :
Connect-AzAccount
# Get all virtual networks in the subscription
$vnetList = Get-AzVirtualNetwork
foreach ($vnet in $vnetList) {
Write-Host "Virtual Network: $($vnet.Name), Resource Group: $($vnet.ResourceGroupName)"
# Get all subnets in the virtual network
$subnetList = Get-AzVirtualNetworkSubnetConfig -VirtualNetwork $vnet
foreach ($subnet in $subnetList) {
Write-Host " Subnet Name: $($subnet.Name), Address Prefix: $($subnet.AddressPrefix)"
}
Write-Host ""
}
You can modify the same to achieve your specific use case.
Please click " accept as answer " if this helps.