Function to display username once and devices of user from Device Afinity

This topic contains 1 reply, has 2 voices, and was last updated by Profile photo of Don Jones Don Jones 7 months, 2 weeks ago.

  • Author
    Posts
  • #38194
    Profile photo of Graham Beer
    Graham Beer
    Participant

    I'm working on a powershell script that gets the device affinity of the user to the device. i could have, for example, one user attached to 4 devices. I want to create a small function to display the users and the device. But here's thing, i want to display the username once and the devices associated with the user.
    Currently all i get back is the same username, for example, 4 times for each device. This is what i have :

    
    $devices = Get-CMDevice -CollectionName 'Visio 2010 Multiple Devices'
    $Return = $devices | foreach { @( Get-CMUserDeviceAffinity -UserName $_.UserName) }
    $Return | % { Write-Output "$($_.UniqueUserName | select -Unique ) : $($_.ResourceName)" }
    
    

    How can i achieve this ?

    Thanks

  • #38300
    Profile photo of Don Jones
    Don Jones
    Keymaster

    So, not being familiar with the CM commands, I guess I'm not sure what output you ARE getting and what output you WANT to get. Can you provide examples?

You must be logged in to reply to this topic.