List all the vm in a particular Subnet in Azure
问题 Just wondering how to retrieve the VMs details in a given particular subnet in Azure. I have used the below but it does not work anymore in powershell (Cloud shell) Listing all azure vm belonging to particular subnet Any help will be appreciated. Thanks 回答1: The following code snippet has been tested against my environment : $vms = Get-AzVM $tgtSubnet = "MySubnet" foreach($vm in $vms) { $networkInterface = Get-AzNetworkInterface -Name ($vm.NetworkProfile.NetworkInterfaces[0].Id.Split('/')[-1]