【问题标题】:list substring (I think thats what it is called) from string output从字符串输出中列出子字符串(我认为这就是所谓的)
【发布时间】:2016-12-02 15:20:20
【问题描述】:

我有一个命令,它给了我以下信息:

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

特性
----------
@{provisioningState=成功;资源Guid=XXX; peerings=System.Object[];授权=系统.对象[];服务提供者属性=;电路提供...

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

【问题讨论】:

  • ... | select -Expand properties | select -Expand provisioningState
  • 您到底需要什么? “成功”的价值?您已经在使用 |在您的示例中选择(即选择对象)。你不能用那个吗?

标签: powershell


【解决方案1】:

这可能有助于获取 ProvisioningState:

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

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

AFAIK 选择不适用于哈希表,属性是哈希表(从输出推断)

【讨论】:

    猜你喜欢
    • 2021-07-10
    • 1970-01-01
    • 2014-06-29
    • 2014-08-07
    • 1970-01-01
    • 1970-01-01
    • 2019-04-30
    • 2012-09-14
    • 1970-01-01
    相关资源
    最近更新 更多