Author Posts

October 16, 2013 at 6:03 am

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

October 16, 2013 at 10:45 am

I create a file with some sample output

UserDisplayName, devicetype

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}



and got this output

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

which I think is what you want

October 16, 2013 at 5:38 pm

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.


UserDisplayName DeviceType DeviceModel DeviceUserAgent
rcanis Android DROID RAZR Android/MIAndroidEmail-4.2.1-
bcouvril BlackBerry Q5 SQR100-2 RIM-Q5-SQR100-2/
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/