how to get unique value from an array of hashtable in powershell?
$h1 = @{a=1;b=2};
$h2 = @{a=3;b=4};
$h3 = @{a=1;b=2};
$h = $h1,$h2,$h3
I want to remove duplicate value ($h1 or $h3) from $h.
thanks!
You can try something like this:
$h | select @{ Expression = { "$($_.Keys):$($_.Values)" }; Label ="AsString" }, @{ Expression ={$_}; Label = "Hash" } -unique
| select -expand Hash
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With