I am trying to get list of all vnet2 peering in one tenant ,that is having many subscriptions.
Ben,
Welcome to the forum.
What have you tried so far? Please share your code and what is not working as expected or what error messages do you get.
Please notice - we love to help you with code you wrote but we do not write ready to use code or solutions on request.
I am playing with this below i got online,but this doesnt specifically give me vnet2 .If you can give some more hint how I can approach that will help me.
Thanks you!!!
Get-AzSubscription | Foreach-Object {
$sub = Set-AzContext -SubscriptionId $_.SubscriptionId
$vnets = Get-AzVirtualNetwork
foreach ($vnet in $vnets) {
[PSCustomObject]@{
Subscription = $sub.Subscription.Name
Name = $vnet.Name
Vnet = $vnet.AddressSpace.AddressPrefixes -join ', ’
Subnets = $vnet.Subnets.AddressPrefix -join ', ’
}
}
} | Export-Csv -Delimiter “;” -Path “VnetList.csv”
Where did you get this code? Why don’t you ask where you got it to help you modifying it?
I don’t have access to Azure right now and I don’t know what vnet2 is. Is it a name you use for your virtual networks or is an official name used by MSFT for a resource in Azure?
What’s the output like when you run …
Get-AzVirtualNetwork
??
And BTW:
When you post code please format it as code using the preformatted text button ( </> ). Simply place your cursor on an empty line, click the button and paste your code.
Thanks in advance.