我目前正在研究一個腳本,該腳本會從組織的終止僱員中刪除會議請求。我發現這一個作爲參考(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。 –