我怎样才能从ExchangeOnline大量删除所有旧的移动设备?

从Exchange 2010迁移到Office365和ExchangeOnline之后,我的用于删除移动设备的脚本似乎只是生成了一个watson dump,将我踢出去并失败。 有没有人有任何修改工作?

原始脚本(修改为显示mobiledevice而不是activesyncdevice)

$DevicesToRemove = Get-MobileDevice -result unlimited | Get-MobileDeviceStatistics | where {$_.LastSuccessSync -le (Get-Date).AddDays("-3")} $DevicesToRemove | foreach-object {Remove-MobileDevice ([string]$_.Guid) -confirm:$false}

我试过的另一个脚本,试图删除,但要求确认每一个!

Get-CASMailbox -ResultSize unlimited –Filter {(HasActiveSyncDevicePartnership -eq $true) -AND (name -notlike "cas*") -AND (name -notlike "DiscoverysearchMailbox*")} | ForEach {Get-MobileDeviceStatistics -Mailbox $_.Identity | Where-Object {$_.LastSuccessSync -le ((Get-Date).AddDays("-14"))} | Remove-MobileDevice}

尝试确认选项:

 Get-CASMailbox -ResultSize unlimited –Filter {(HasActiveSyncDevicePartnership -eq $true) -AND (name -notlike "cas*") -AND (name -notlike "DiscoverysearchMailbox*")} | ForEach {Get-MobileDeviceStatistics -Mailbox $_.Identity | Where-Object {$_.LastSuccessSync -le ((Get-Date).AddDays("-14"))} | Remove-MobileDevice -Confirm:$false}