我目前正在编写一个脚本,用于删除组织终止员工的会议请求。我发现这个作为参考(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。我的帐户也拥有所有者权限。
答案 0 :(得分:1)
您似乎没有可用的cmdlet。所以检查正确的版本。
请执行以下操作并查看:
创建“邮箱导入 - 导出管理”角色组并成为其成员。
要创建角色组,请使用:
New-RoleGroup "Mailbox Import-Export Management" -Roles "Mailbox Import Export"
添加成员:
Add-RoleGroupMember "Mailbox Import-Export Management" -Member
除此之外,如果你想搜索,那么你可以像这样使用:
Get-mailbox | Export-Mailbox –AllContentKeywords "thekeysyouwant" –TargetMailbox Administrator –TargetFolder 'foldername'
希望它有所帮助。