We have a script that runs and removes all activesync mobile device relationships over 30 days old in our Office 365 environment.
Here is the part of the script that runs to remove the devices and has been working for us for several months:
$DevicesToRemove = Get-MobileDevice -result unlimited | Get-MobileDeviceStatistics | where {$_.LastSuccessSync -le (Get-Date).AddDays("-30")} $DevicesToRemove | foreach-object {Remove-MobileDevice ([string]$_.Guid) -confirm:$false}
However now if I run it I get an error, even if I just run Get-MobileDevice -result unlimited | Get-MobileDeviceStatistics I get the following error:
WARNING: An unexpected error has occurred and a Watson dump is being generated: Object reference not set to an instance of an object. Object reference not set to an instance of an object. + CategoryInfo : NotSpecified: (:) [Get-MobileDeviceStatistics], NullReferenceException + FullyQualifiedErrorId : System.NullReferenceException,Microsoft.Exchange.Management.Tasks.GetMobileDeviceStatist ics + PSComputerName : outlook.office365.com
Any idea what has changed in Office 365, is this due to throttling limits?
submitted by /u/Asheville101
[link] [comments]
The post Watson Error when removing activesync relationships in Office 365 via powershell. appeared first on How to Code .NET.