PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,502 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I am runing
$vn = Get-AzVirtualNetwork -Name mynet
$vn.Subnets | Select Name, AddressPrefix,id | sort AddressPrefix
How may I list resourcegroup
name which is in id?
are you asking for resource group of vn?
$vn.ResourceGroupName
or do you expect subnets to have different resourcegroupname?
in that case by string manipulation you get the ResourceGroupNameFromId via
$vn.Subnets | Select Name, AddressPrefix,@{n='ResourceGroupNameFromId';e={((($_.Id -split '/resourceGroups/')[1]) -split '/providers/')[0]}} | sort AddressPrefix
property 'ID' was replaced by 'ResourceGroupNameFromId'
regards