troubleshooting Question

Need to delete mobile device access to 365 Mailboxes

Avatar of Roger Leech
Roger LeechFlag for United States of America asked on
PowershellMicrosoft 365Exchange
2 Comments1 Solution102 ViewsLast Modified:
I'm trying to write a simple PS script to remove EAS partnerships to a mailbox.  This only needs to be done 1 by 1, but Ideally I could import a CSV for it.  The CSV import I think I can do, but I'm having trouble with the 1 at a time script.  I'm really basic when it comes to PS so I'd appreciate any help - for each and variables are super confusing.  

This is what I have:  
$User = Read-Host -Prompt "Who's Mobile Devices are you going to nuke?  Enter username"
$Devices = Get-MobileDevice -Mailbox $user
ForEach ($Device in $Devices) 
        Remove-MobileDevice $Device
Clear-Variable User,Name,Devices
But I keep getting this:
Cannot process argument transformation on parameter 'Identity'. Cannot convert the "Persons Name\ExchangeActiveSyncDevices\iPad§Q5F3123456KHLAGK41P7VO" value of type 
"Deserialized.Microsoft.Exchange.Data.Directory.SystemConfiguration.MobileDevice" to type "Microsoft.Exchange.Configuration.Tasks.MobileDeviceIdParameter".
    + CategoryInfo          : InvalidData: (:) [Remove-MobileDevice], ParameterBindin...mationException
    + FullyQualifiedErrorId : ParameterArgumentTransformationError,Remove-MobileDevice
    + PSComputerName        :

Then I'll do
Set-CASMailbox username -ActiveSyncDeviceIDs $null
as a finisher.  

What do you think of this process?  

Since I know you're curious, we just migrated to G-Suite and I want to prevent people from accidentally accessing their 365 mailbox on mobile.
Darrell Porter
Enterprise Business Process Architect

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros