As most of you already know the "-ExpandProperty" parameter let's you enumerate the values of an incoming object as single value.  For example, if you run the command below without the "-ExpandProperty".

Get-AzLocalNetworkGateway -ResourceGroupName "network-rg"

You will get output like this:

Name                     : my-lng

ResourceGroupName        : network-pd-rg

Location                 : southcentralus

Id                       : /subscriptions/GUID/resourceGroups/network-pd-rg/providers/Microsoft.Network/localNetworkGateways/qco-houdc-lng

Etag                     : W/"GUID"

ResourceGuid             : GUID

ProvisioningState        : Succeeded

Tags                     :

                           Name                     Value

                           =======================  =======

                           owner                    Network

                           external-facing          No

                           cost-center              IT

                           regulatory-data          no

                           project-name             PD

                           department               IT

                           critical-infrastructure  Yes

                           environment              PD

 

GatewayIpAddress         : 4.50.4.28

LocalNetworkAddressSpace : {

                             "AddressPrefixes": [

                               "10.100.0.0/16",

                               "10.101.0.0/16",

                               "10.102.0.0/16",

                               "10.103.0.0/16",

                               "10.104.0.0/16", 

                             ]

                           }

BgpSettings              : null

 

But what if you just want a simple list of all LocalNetworkAddressSpace?  You can use -ExpandProperty but the trick is you have to use it twice!  See sample below.  If you only pass it once you will still not get desired list, you must expand the properties two times because the expanded property is a list in this case.

Get-AzLocalNetworkGateway -ResourceGroupName "network-rg" | Select -ExpandProperty LocalNetworkAddressSpace | Select -ExpandProperty AddressPrefixes | FT

This will product the output desired as shown below.

10.100.0.0/16

10.101.0.0/16

10.102.0.0/16

10.103.0.0/16

10.104.0.0/16

 

Hope this helps someone!