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
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

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.

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