【发布时间】:2016-11-28 22:04:25
【问题描述】:
我正在编写一个脚本以从我们的交换服务器中删除所有 EAS 设备。 (强制使用仅基于 REST 的客户端)
# 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
我收到以下错误:
无法处理参数“邮箱”的参数转换。无法将值“支持帐户”转换为类型 “Microsoft.Exchange.Configuration.Tasks.MailboxIdParameter”。错误:“无法将哈希表转换为 以下类型:Microsoft.Exchange.Configuration.Tasks.MailboxIdParameter。哈希表到对象的转换不是 受限制的语言模式或数据部分支持。"
我的问题是如何获取所有邮箱,然后遍历Get-MobildeDeviceStatistics?
我什至无法在网上搜索更多信息,例如:
【问题讨论】:
标签: powershell exchange-server