【发布时间】:2017-10-07 07:05:45
【问题描述】:
我目前正在编写一个脚本,该脚本将删除组织中已离职员工的会议请求。我发现这个作为参考(Deleting Meeting Requests made by terminated users),由于我的错误,我无法让它为我工作。
这是我的脚本
Add-Type -Path "C:\Program Files (x86)\Microsoft\Exchange\Web Services\2.1\Microsoft.Exchange.WebServices.dll"
$UserCredential = Get-Credential
$session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $session -AllowClobber
#Enter-PSSession $session
$rooms = Get-Mailbox -RecipientTypeDetails RoomMailbox -ResultSize Unlimited
$count=$rooms.count
$TerminatedUsers = Get-Content D:\Work\SHAR78\resignedEmployees.txt
Write-Host "count of rooms " $count
foreach ($user in $TerminatedUsers) {
Write-Host "terminated user" $user
foreach($room in $rooms) {
$room | Search-Mailbox -searchquery "kind:calendar from:$($user)" -targetmailbox admin@admin.com -TargetFolder "SearchData" -logonly -loglevel full
#-targetmailbox administrator@domain.com -targetfolder "Deleting Meeting" -deletecontent -force
}
}
我已连接到 Exchange Online,所以我不确定为什么没有导入 Search-Mailbox。我的帐户也有所有者权限。
【问题讨论】:
-
您是否查看了从会话中导入的内容?可能没有暴露,可能是你权限不够?
-
此 cmdlet 在本地 Exchange Server 2016 和基于云的服务中可用。那么,能否请您使用 get-command 并查看它是否可用。
-
嗨@Seth 我的帐户需要什么权限?我使用 get-command 进行了检查,但找不到搜索邮箱。我只看到 Search-MailboxAuditLog。
-
如果您现在购买新的 Office365 服务,它将是 Exchange 2013 CU1,这是当时 Exchange 的最新版本 - 较旧的 Office365 组织将混合 2010 年和 2013 年,具体取决于他们购买的时间。现在我认为有更新的版本可用。不确定
-
根据this,您需要在(默认)组“发现管理”或“组织管理”中。或者,您可以将“邮箱搜索”角色分配给自定义组。
标签: powershell outlook office365 exchange-server