Hi, just wondering if someone could help me understand why my script fails? RRS feed

  • Question

  • $User= Read-Host -Prompt "Enter Username" 

    $Mailbox=Read-Host -Prompt "Enter Mailbox"

    Add-MailboxPermission -Identity $Mailbox -user $User -AccessRights FullAccess -WhatIf

    Add-ADPermission $Mailbox -ExtendedRights Send-As -user $User -whatif

    Add-ADPermission $Mailbox -User $User -Extendedrights "Send As" -whatif


    I get this error:

    [PS] C:\Windows\system32>$User= Read-Host -Prompt "Enter Username"
    Enter Username: User1
    [PS] C:\Windows\system32>
    [PS] C:\Windows\system32>$Mailbox=Read-Host -Prompt "Enter Mailbox"
    Enter Mailbox: mailbox1
    [PS] C:\Windows\system32>Add-MailboxPermission -Identity $Mailbox -user $User -AccessRights FullAccess -WhatIf
    What if: Adding Mailbox Permission on 'mailbox1' for User 'User1' with AccessRights ''FullAccess''.
    [PS] C:\Windows\system32>Add-ADPermission $Mailbox -ExtendedRights Send-As -user $User -whatif
    mailbox1 wasn't found. Please make sure you've typed it correctly.
        + CategoryInfo          : NotSpecified: (:) [Add-ADPermission], ManagementObjectNotFoundException
        + FullyQualifiedErrorId : [Server=TestServerExchange,RequestId=8aaf17a3-d6c1-47e7-ae05-5160614af63a,TimeStamp=10.11.201
       6 15:37:50] [FailureCategory=Cmdlet-ManagementObjectNotFoundException] 533A71B,Microsoft.Exchange.Management.Recip
        + PSComputerName        : TestServerExchange.local

    • Moved by Bill_Stewart Friday, December 30, 2016 8:42 PM First, read the error message
    Thursday, November 10, 2016 3:49 PM

All replies

  • The error is pretty clear: "mailbox1 wasn't found. Please make sure you've typed it correctly."


    Thursday, November 10, 2016 4:19 PM
  • just noticed some other errors :) so It's all good now. But I can do get-mailbox mailbox1 and it shows up.
    Friday, November 11, 2016 9:05 AM