Removing duplicate values from a PowerShell array Ask Question

Removing duplicate values from a PowerShell array Ask Question

How can I remove duplicates from a PowerShell array?

$a = @(1,2,3,4,5,5,6,7,8,9,0,0)

ベストアンサー1

Use Select-Object (whose alias is select) with the -Unique switch; e.g.:

$a = @(1,2,3,4,5,5,6,7,8,9,0,0)
$a = $a | select -Unique

おすすめ記事