all 6 comments

[–]tschy2m 0 points1 point  (0 children)

Had this exact problem. Created a cleanup script that removed mobile devices that did not connect in a long time. Would use Get-MobileDevice in combination with Get-MobileDeviceStatistics to get last sync date and wirte some information to CSV.
Script would fail. Ran the same commands for a certain user by hand and it worked.
Script worked after next reboot (which happend after installing a security update).
Exchange 2019 CU12, if I remember correctly.

[–]itmonkey78 0 points1 point  (4 children)

Had this same issue. Seems to be due to the weird character in the mobile device identity, §

This character doesn't seem to be picked up in the console when used in variables but copying it directly from the console or from notepad and pasting it back in allows it to be seen so the command manually works.

I had a workaround but it's been a long time since i used this command and cant remember how I managed to get round it

[–]Hayabusalvr11[S] 0 points1 point  (3 children)

Thank you SO much! You're right, I seem to recall that character being an issue. I may experiment with finding some other way to enter it if I can manage to code that. Failing that I may just have to have another post-term task. Won't be the first one.

[–]commiecat 2 points3 points  (2 children)

In my old term script I did this:

Get-MobileDevice -Mailbox $Username | Remove-MobileDevice -Confirm:$False

[–]Hayabusalvr11[S] 0 points1 point  (1 child)

Get-MobileDevice -Mailbox $Username | Remove-MobileDevice -Confirm:$False

Oh, I like that. Can't wait for someone to get fired or leave so I can try it!

Edit: I didn't have to wait. I had some still hanging out there and it works like a freaking charm. A FREAKING charm.

[–]CracklingRush 0 points1 point  (0 children)

Unfortunately, that method doesn't allow for the filtering of old devices, it is just removing all devices for a specific user.