【问题标题】:The "Confirm" parameter can't be used on the "Set-Mailbox"“确认”参数不能在“设置邮箱”上使用
【发布时间】:2018-03-23 14:07:03
【问题描述】:

我正在尝试为使用管理员帐户的用户设置邮箱权限。

试试{

Set-Mailbox $UserPrincipleName -AuditEnabled $True -AuditLogAgeLimit 
"03.00:00:00" -AuditDelegate "SoftDelete", "HardDelete", "SendAs", "Create", 
"FolderBind" -Confirm:$false

}赶上{

if($Error)
   {
     Write-Host "Error"
   }     

}

我无法在 catch 块 ($Error) 中捕获此错误。

错误:: 不能在“Set-Mailbox”cmdlet 上使用“Confirm”参数,因为它不存在于当前用户的角色定义中。

检查分配给您的管理角色,然后重试。

任何线索将不胜感激。干杯...

【问题讨论】:

  • 你不需要在catch 块中说if ($Error)。你已经知道有一个错误,因为你在catch
  • 正如Bill所说,这里不需要在catch块中使用if进行确认,尝试不提及-Confirm参数,看看它是否要求确认。

标签: powershell try-catch powershell-2.0 exchange-server


【解决方案1】:

添加以将-ErrorAction Stop 添加到Set-Mailbox cmdlet:

Set-Mailbox $UserPrincipleName -AuditEnabled $True -AuditLogAgeLimit 
"03.00:00:00" -AuditDelegate "SoftDelete", "HardDelete", "SendAs", "Create", 
"FolderBind" -ErrorAction Stop

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-23
    • 2018-09-02
    • 2023-03-20
    相关资源
    最近更新 更多