Forum Discussion

Dabby's avatar
Dabby
Copper Contributor
Apr 29, 2022
Solved

get-unique command get me wrong results in powershell

Hello,   i need some help get the unique values inside a variable or array. The goal was to count member of ad groups. we could no be sure, if users are in multiple groups so i wanted to  put the ...
  • Kevin_Morgan's avatar
    Apr 29, 2022

    Dabby 

     

    Can you try the following command to get unique objects by specific property name.

     

    $users.count
    
    $A = $users | Select-Object -Unique -Property name
    
    $A.count

     

    Read this post for more details : https://morgantechspace.com/2021/11/find-unique-object-items-by-property-in-powershell-array.html 

Resources