get-mobiledevicestatistics command exchange online

Need assistance with a script. The script works great, except for one thing. I cant seem to figure out how to export the primary smtp address for the mailbox. Script is below. Thank you very much for any assistance.


$today = get-date -format yyyyMMdd

$thisdevice =@()
$incre = 0
$o365users = import-csv C:\temp\MobileDevice\mobiledevice_$today.csv
foreach ($item in $o365users)
$userdevices= get-mobiledevicestatistics -mailbox $item.alias
if($null -ne $userdevices) {
foreach ($device in $userdevices) {
$device=$device |Select-Object deviceos,DeviceModel,lastsuccesssync,guid
$thisdevice+=new-object psobject -property @{loginID=$item.alias;Name=$;Email=$item.primarysmtpaddress;Model=$device.devicemodel;Deviceos=$device.deviceos;lastsuccesssync=$device.lastsuccesssync;guid=$device.guid}
#if($device.lastsuccesssync -lt (get-date).addDays(-30)){
#remove-mobiledevice $device.guid#
$thisdevice |export-csv -append c:\temp\mobiledevice\mobiledeviceoutput_$today.csv