gpt4 book ai didi

powershell - Powershell-合并两个Note属性

转载 作者:行者123 更新时间:2023-12-03 01:25:49 26 4
gpt4 key购买 nike

如何在Powershell中将两个Note属性合并在一起?
以下查询返回实例列表,但我想合并“注释属性”,如下所示。

$((Get-Counter '\Process(Chrome*)\ID Process' -ErrorAction SilentlyContinue).CounterSamples | % {[regex]$a = "^.*\($([regex]::Escape($_.InstanceName))(.*)\).*$";[PSCustomObject]@{InstanceName=$_.InstanceName;InstanceId=$a.Matches($($_.Path)).groups[1].value}}) 
查询的输出是:
InstanceName                                                InstanceId
------------ ----------
Chrome #2
Chrome #1
Chrome
但是我希望输出是这样的。
InstanceName
------------
Chrome#2
Chrome#1
Chrome

最佳答案

您只需要将第一个属性的表达式值更改为:

@{InstanceName="$($_.InstanceName)$($a.Matches($($_.Path)).groups[1].value)"}})
在全:
(Get-Counter '\Process(Chrome*)\ID Process' -ErrorAction SilentlyContinue).CounterSamples | % {[regex]$a = "^.*\($([regex]::Escape($_.InstanceName))(.*)\).*$";[PSCustomObject]@{InstanceName="$($_.InstanceName)$($a.Matches($($_.Path)).groups[1].value)"}}

关于powershell - Powershell-合并两个Note属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63225223/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com