Get-MobileDevice and multiple device per user

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of debratton debratton 3 years, 8 months ago.

  • Author
    Posts
  • #10781
    Profile photo of debratton
    debratton
    Participant

    Get-MobileDevice | Select UserDisplayName,devicetype

    Problem, individuals have multiple devices, so export shows

    UserDisplayName devicetype
    =============== ==========
    dsmith Android
    dsmith iPhone

    How can I make results

    UserDisplayName devicetype
    =============== ==========
    dsmith Android,iPhone

  • #10796
    Profile photo of Richard Siddaway
    Richard Siddaway
    Moderator

    I create a file with some sample output

    UserDisplayName, devicetype
    dsmith,android
    dsmith,iphone
    asmith,android
    asmith,iphone
    asmith,ipad
    jsmith,iphone
    fsmith,android

    I then ran this against it

    $devices = @{}

    Import-Csv data.txt |
    sort userdisplayname |
    foreach {
    if ($devices[$_.userdisplayname]){
    $devices[$_.userdisplayname] = $devices[$_.userdisplayname] + "," + $_.devicetype
    }
    else {
    $devices += @{$_.userdisplayname = $_.devicetype}
    }

    }

    $devices

    and got this output

    Name Value
    —- —–
    asmith android,ipad,iphone
    fsmith android
    dsmith android,iphone
    jsmith iphone

    which I think is what you want

  • #10806
    Profile photo of debratton
    debratton
    Participant

    Thanks Richard,

    Unfortunately I unable to take your code and add what was actually needed. Can you show how I would includes DeviceModel and DeviceUserAgent in your code.

    Thanks again for your assistance.

    David

    UserDisplayName DeviceType DeviceModel DeviceUserAgent
    rcanis Android DROID RAZR Android/MIAndroidEmail-4.2.1-1.1.0.0
    bcouvril BlackBerry Q5 SQR100-2 RIM-Q5-SQR100-2/10.1.0.2342
    mbaumeis iPhone iPhone4C1 Apple-iPhone4C1/1101.501
    bcouvril Android GT-I9100 TouchDown(MSRPC)/8.1.00052/ENCRYPTDEVICE,ENCRYPTSD
    slaurac iPhone iPhone5C2 Apple-iPhone5C2/1101.501
    slaurac BlackBerry Z10 STL100-2 RIM-Z10-STL100-2/10.1.0.4633

You must be logged in to reply to this topic.