Avatar of Anthony K O365
Anthony K O365
Flag 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?
PowershellExchange

Avatar of undefined
Last Comment
Anthony K O365

8/22/2022 - Mon
Jose Gabriel Ortega Castro

Whats the information inside "users.txt" ?
is this in Exchange 2013/16/19? or exchange online?
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
Anthony K O365

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck