如何从PowerShell中的哈希表数组中获取唯一值?
$h1 = @{a=1;b=2};
$h2 = @{a=3;b=4};
$h3 = @{a=1;b=2};
$h = $h1,$h2,$h3
Run Code Online (Sandbox Code Playgroud)
我想从$ h中删除重复值($ h1或$ h3).
谢谢!
你可以尝试这样的事情:
$h | select @{ Expression = { "$($_.Keys):$($_.Values)" }; Label ="AsString" }, @{ Expression ={$_}; Label = "Hash" } -unique
| select -expand Hash
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3525 次 |
| 最近记录: |