从字符串输出中列出子字符串(我认为这就是所谓的)

时间:2016-12-02 00:58:42

标签: powershell

我有一个命令,它给了我以下内容:

PS C:\Windows\system32> Get-AzureRmResource -ResourceGroupName XXX -ResourceType Microsoft.Network/expressRouteCircuits -isCollection -ApiVersion 2016-09-01 | select Properties

Properties
----------
@{provisioningState=Succeeded; resourceGuid=XXX; peerings=System.Object[]; authorizations=System.Object[]; serviceProviderProperties=; circuitProvisio...

现在我只想从属性中捕获provisioningState=value

1 个答案:

答案 0 :(得分:0)

this might help for fetching the provisioningState:

$resource =  Get-AzureRmResource -ResourceGroupName XXX -ResourceType Microsoft.Network/expressRouteCircuits -isCollection -ApiVersion 2016-09-01 | select -expand Properties
$resource[provisioningState]

or

Get-AzureRmResource -ResourceGroupName XXX -ResourceType Microsoft.Network/expressRouteCircuits -isCollection -ApiVersion 2016-09-01 | select -expand Properties | %{$_.provisioningState}

AFAIK select does not work on hash table and properties is a hash table (infering from the output)