Link to home
Create AccountLog in
Avatar of Anthony K O365
Anthony K O365Flag for United States of America

asked on

Need a PS script to get list of users with mailbox permission

Here is the script I'm using to get all mailboxes where 'HelpDeskUser' has full permission to. The text file contain SamaccountName of the mailboxes I'm interested.

$emails = GC D:\Data\users.txt
$emails | ForEach-Object {
      Get-Mailbox -Identity $_ | Get-MailboxPermission  |? {$_.user -like "HelpDeskUser*" }} |select name, primarysmtpAddress,alias |out-file D:\Data\mailboxPermission.txt


However, I'm not getting any output. What I am I doing wrong?
Avatar of J0rtIT
J0rtIT
Flag of Venezuela, Bolivarian Republic of image

Whats the information inside "users.txt" ?
is this in Exchange 2013/16/19? or exchange online?
Avatar of Anthony K O365

ASKER

As mentioned, it contains the samaccountName of the mailboxes in question. This is an Exchange 2016 On Premier org
Thanks!


ASKER CERTIFIED SOLUTION
Avatar of Anthony K O365
Anthony K O365
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account