2017-05-09 96 views
0

我目前正在研究一个脚本,该脚本会从组织的终止雇员中删除会议请求。我发现这一个作为参考(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,所以我不会知道为什么没有被导入的搜索邮箱。我的帐户也拥有所有者权限。

+0

您是否检查了会话中正在导入的内容?也许它没有公开,这可能是因为你没有足够的权限? – Seth

+0

此cmdlet在本地Exchange Server 2016和基于云的服务中可用。那么,您可以使用get-command来查看它是否可用。 –

+0

Hi @Seth我的帐户需要什么权限?我检查使用get-command,我找不到搜索邮箱。我只看到Search-MailboxAuditLog。 –

回答

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' 

希望它有帮助。

+0

我现在得到这个:术语'Export-Mailbox'不被识别为cmdlet,函数,脚本文件或可操作程序的名称。检查名称的拼写,或者如果包含路径,请验证路径是否正确,然后重试。 –

+0

我相信交换pssnapin有一些问题。你能否请在另一个盒子试试,并检查 –

+0

尝试此链接。 [LINK](HTTP://www.aurelp。com/tag/resolved-export-mailbox-and-import-mailbox-commands-not-recognized /) –

相关问题