locked
Adding multiple users with full access not working in shell RRS feed

  • Question

  • I was given a list of 22 users to add to a newly created mailbox today and extracted just their SAMAccountNames into a .txt file, and then tried using the following to add them all to a mailbox (called "mailbox" here to obscure real accounts)

    $users = get-content c:\powershell\temp\users.txt
    
    Foreach ($user in $users)
        {Add-MailboxPermission -Identity "mailbox" -User "$user" -AccessRights FullAccess -InheritanceType all }

    As I often do before I mark work as complete, I went to check it and opened up the EMC to the mailbox in question, right-clicked and selected "Manage Full Access Permission" - sure enough, it only showed 2 users. I figured it might be some kind of replication issue between our cluster members, so I opened up a few of the Exchange servers directly and saw the same result on the EMC running directly on the server. I ran get-mailboxpermission from the servers and got the same thing.

    I tried the script again, this time putting a sleep -5 as the 2nd line of the foreach loop and it managed to get 17 of my 22 users to be added. I checked and double-checked the .txt file to ensure there were no spaces, and ran the script again ... this time 20 out of the 22 were on there.

    I finally just manually tracked down the two missing users and added them through EMC.

    Anyone else ever have behaviours/issues like this?


    zarberg@gmail.com

    Friday, September 11, 2015 7:15 PM

All replies

  • I think you need to do it from OU basis. Place all 22 users in OU and run the command to extract the file.

    UMESH DEUJA MCP,MCTS,MCSA,CCNA

    Thursday, February 18, 2016 11:48 PM
  • It's an AD replication issue, more than likely.  Depending on how large your organization is, you may be hitting multiple domain controllers and need to wait for the replication and convergence.  You can use the -DomainController parameter to specify that all operations be performed against the same DC.
    Tuesday, April 25, 2017 7:35 PM