Forum Discussion
Christian Forjahn
Mar 25, 2017Brass Contributor
PowerShell: Find VNet of an ARM VM
Hi everyone,
it took me quite some time to find a way to get the VNet an ARM VM belongs to by using PowerShell. I don't think this is the perfect solution, but I would like to share it in order...
Jan Steenbeek
Oct 18, 2017Copper Contributor
Not really innovating, just bringing it down to a single line:
$vnetName = Get-AzureRmVirtualNetwork | % {if($_.Subnets.IpConfigurations.Id.StartsWith($vm.NetworkProfile.NetworkInterfaces.Id)){return $_.Name}}