我目前正在研究一个脚本,该脚本会从组织的终止雇员中删除会议请求。我发现这一个作为参考(Deleting Meeting Requests made by terminated users),我不能让它为我工作,因为我的错误。术语'搜索邮箱'不被识别为cmdlet的名称Exchange Online Powershell
这是我的脚本
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 [email protected] -TargetFolder "SearchData" -logonly -loglevel full
#-targetmailbox [email protected] -targetfolder "Deleting Meeting" -deletecontent -force
}
}
我已连接到Exchange Online,所以我不会知道为什么没有被导入的搜索邮箱。我的帐户也拥有所有者权限。
您是否检查了会话中正在导入的内容?也许它没有公开,这可能是因为你没有足够的权限? – Seth
此cmdlet在本地Exchange Server 2016和基于云的服务中可用。那么,您可以使用get-command来查看它是否可用。 –
Hi @Seth我的帐户需要什么权限?我检查使用get-command,我找不到搜索邮箱。我只看到Search-MailboxAuditLog。 –