# How do I get list of all vnet2 peering in an organization

**URL:** <https://forums.powershell.org/t/how-do-i-get-list-of-all-vnet2-peering-in-an-organization/17724>\
**Category:** PowerShell Help\
**Created:** [October 10, 2021, 5:56pm UTC](https://forums.powershell.org/t/how-do-i-get-list-of-all-vnet2-peering-in-an-organization/17724 "2021-10-10T17:56:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Efi20005](https://avatars.discourse-cdn.com/v4/letter/e/e274bd/32.png) [@Efi20005](https://forums.powershell.org/u/Efi20005)\
**Post date:** [October 10, 2021, 5:56pm UTC](https://forums.powershell.org/t/how-do-i-get-list-of-all-vnet2-peering-in-an-organization/17724/1 "2021-10-10T17:56:14Z")

</div>

I am trying to get list of all vnet2 peering in one tenant ,that is having many subscriptions.

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [October 10, 2021, 7:01pm UTC](https://forums.powershell.org/t/how-do-i-get-list-of-all-vnet2-peering-in-an-organization/17724/2 "2021-10-10T19:01:21Z")

</div>

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. 😉

---

<div class="post-metadata">

**Author:** ![Efi20005](https://avatars.discourse-cdn.com/v4/letter/e/e274bd/32.png) [@Efi20005](https://forums.powershell.org/u/Efi20005)\
**Post date:** [October 11, 2021, 6:08pm UTC](https://forums.powershell.org/t/how-do-i-get-list-of-all-vnet2-peering-in-an-organization/17724/3 "2021-10-11T18:08:29Z")

</div>

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](http://sub.Subscription.Name)  
Name = $vnet.Name  
Vnet = $vnet.AddressSpace.AddressPrefixes -join ', ’  
Subnets = $vnet.Subnets.AddressPrefix -join ', ’  
}  
}  
} | Export-Csv -Delimiter “;” -Path “VnetList.csv”

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [October 11, 2021, 8:35pm UTC](https://forums.powershell.org/t/how-do-i-get-list-of-all-vnet2-peering-in-an-organization/17724/4 "2021-10-11T20:35:20Z")

</div>

> [@Efi20005](#):
>
> I am playing with this below i got online

Where did you get this code? Why don’t you ask where you got it to help you modifying it? 😉

> [@Efi20005](#):
>
> but this doesnt specifically give me vnet2

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 …

```auto
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.

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:21pm UTC](https://forums.powershell.org/t/how-do-i-get-list-of-all-vnet2-peering-in-an-organization/17724/5 "2024-05-16T20:21:11Z")

</div>


