title: Remove Duplicates From License Array
body: <p>I'm having an issue removing duplicates from my array.</p>
  
  <pre><code>$DataSheet = Import-Csv C:\Temp\Groups.CSV
  $LicenseData = @()
  
  foreach ($Group in $DataSheet) {
      $GroupMembership = Get-ADGroupMember $Group.Name | Select SamAccountName
      foreach ($Member in $GroupMembership) {
          $LicenseInfo = "" | Select "ID","GroupName","EngineLicense","UserLicense"
          $LicenseInfo.ID = $Member.SamAccountName
          $LicenseInfo.GroupName = $Group.Name
          $LicenseInfo.EngineLicense = $Group.EngineLicense
          $LicenseInfo.UserLicense = $Group.UserLicense
          $LicenseData += $LicenseInfo
      }
  }
  
  $LicenseData | Sort-Object ID |
      Export-Csv C:\Temp\LicenseData.CSV -NoTypeInformation -Force
  $EngineLicense = $LicenseData | Group -Property $EngineLicense |
                   ForEach {$_.Group | Sort-Object EngineLicense -Unique} |
                   Select EngineLicense, ID |
                   Sort-Object EngineLicense
  $UserLicense   = $LicenseData | Group -Property $UserLicense |
                   ForEach {$_.Group | Sort-Object UserLicense -Unique} |
                   Select UserLicense, ID |
                   Sort-Object UserLicense
  </code></pre>
  
  <p>This is an example of what <code>$LicenseData</code> looks like</p>
  
  <pre>
  ID        GroupName EngineLicense UserLicense
  --        --------- ------------- -----------
  TestUser1 Group A   Mobile        Professional
  TestUser1 Group B   ERQA          ERQA
  TestUser1 Group B   ERQA          ERQA
  TestUser2 Group A   Mobile        Professional
  TestUser2 Group B   ERQA          ERQA
  </pre>
  
  <p><code>$EngineLicense</code> looks like</p>
  
  <pre>
  EngineLicense ID
  ------------- --
  ERQA          TestUser1
  Mobile        TestUser1
  </pre>
  
  <p>What I'm trying to do is display each user's consumed licenses, but removing duplicate licenses for a user. Currently the <code>-Unique</code> is removing duplicate engine licenses.</p>
  
  <p>Ideally this is what I envision it to look like. Note that is shows the licenses consumed for both users and removed the duplicate ERQA entry for TestUser1.</p>
  
  <pre>
  EngineLicense ID
  ------------- --
  ERQA          TestUser1
  Mobile        TestUser1
  ERQA          TestUser2
  Mobile        TestUser2
  </pre>