Forum Discussion

Freshie's avatar
Freshie
Copper Contributor
Jul 11, 2024

Help using a file for input

Hello everybody, I am currently using this script to automate a process, the problem, is it only processes one user at a time.

 

Add-MailboxPermission -Identity "USERNAME" -User "sa_sourceone" -AccessRights FullAccess -InheritanceType All -AutoMapping $false

 

I would like to pull in entries from a text file for the USERNAME field so I can process more than one at a  time.

 

Any help would be appreciated,

Thanks.

1 Reply

  • LainRobertson's avatar
    LainRobertson
    Silver Contributor

    Freshie 

     

    Hi, Jeff.

     

    Assuming your input file has one username per line, like this:

     

     

    You can use the following command line to perform the Add-MailboxPermission for each user:

     

    Get-Content -Path "D:\Data\Temp\Forum\forum.txt" | ForEach-Object {
        Add-MailboxPermission -Identity "$_" -User "sa_sourceone" -AccessRights FullAccess -InheritanceType All -AutoMapping $false;
    }

     

    Cheers,

    Lain