我正在使用脚本从我们的交换服务器中删除所有EAS设备。 (强制使用基于REST的唯一客户端)Get-MobileDeviceStatistics上的邮箱迭代
# Login
$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -
AllowRedirection
Import-PSSession $Session
#Removing EAS devices
#
$Mailboxes = Get-Mailbox -ResultSize Unlimited
Foreach ($box in $Mailboxes){ $EASDevices = Get-MobileDeviceStatistics -Mailbox $box | Where-Object {$_.ClientType -like "EAS"};
EASDevices | foreach {$Guid = $_.guid.ToString(); Remove-MobileDevice -id $Guid}}
#@TODO add -Confirm:$False when it is working
我得到以下错误:
Cannot process argument transformation on parameter 'Mailbox'. Cannot convert value "Support Account" to type "Microsoft.Exchange.Configuration.Tasks.MailboxIdParameter". Error: "Cannot convert hashtable to an object of the following type: Microsoft.Exchange.Configuration.Tasks.MailboxIdParameter. Hashtable-to-Object conversion is not supported in restricted language mode or a Data section."
我的问题是如何让所有邮箱,然后通过迭代Get-MobildeDeviceStatistics
?
我没能更进一步,甚至在网上搜索,例如: