【问题标题】:The term 'Search-Mailbox' is not recognized as the name of a cmdlet Exchange Online Powershell术语“搜索邮箱”未被识别为 cmdlet Exchange Online Powershell 的名称
【发布时间】: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


【解决方案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'

希望对你有帮助。

【讨论】:

  • 我现在明白了:“Export-Mailbox”一词未被识别为 cmdlet、函数、脚本文件或可运行程序的名称。检查名称的拼写,如果包含路径,请验证路径是否正确,然后重试。
  • 我认为交换的 pssnapin 存在一些问题。你能不能换一个盒子试试看
  • 试试这个链接。 LINK
  • 您好,感谢您的帮助,我已经解决了这个问题,虽然我不确定我是怎么做到的,我猜是在许可上。但还是谢谢你! :)
  • @PageF.P.T:如果对您有帮助,请投票/接受答案:)
猜你喜欢
  • 1970-01-01
  • 2020-06-12
  • 2019-10-12
  • 2017-12-11
  • 2021-12-09
  • 2020-02-25
  • 2020-04-17
  • 2018-09-30
  • 1970-01-01
相关资源
最近更新 更多