Link to home
Start Free TrialLog in
Avatar of Margarita
Margarita

asked on

Need help with mailbox permissions script

Hi all,

I need help editing this script;.

There is a statement which allows me to import a CSV but it always chooses to get all mailboxes.

Please help x
Avatar of Vasil Michev (MVP)
Vasil Michev (MVP)
Flag of Bulgaria image

Which script might that be?
Avatar of Margarita
Margarita

ASKER

Hi Vasil I didn't upload it ?


I have uploaded it now.
GetMailbozPermissions.txt
Looking at the code, the script will always look for the "C:\temp\test.csv" file, regardless of what value you provide for the $userIDFile parameter.
But I have assigned a list of users which I wanted to check what permissions they have to which mailboxes and it didn't go through the list

It just checked the permissions of all shared mailboxes
Change this line

$objUsers = Import-Csv "C:\temp\test.csv" -Header "UserPrincipalName" $UserIDFile

Open in new window


to this

$objUsers = Import-Csv $userIDFile -Header "UserPrincipalName"

Open in new window


Then pass the path to the CSV file in the userIDFile parameter.
#Check if we have been passed an input file path
      if ($userIDFile -ne "")
      {
            #We have an input file, read it into memory
        $objUsers = Import-Csv $userIDFile -Header "UserPrincipalName"
      }
      else
      {
            #No input file found, gather all mailboxes from Office 365
            $objUsers =Get-Mailbox -Filter {RecipientTypeDetails -eq "SharedMailbox"} -ResultSize Unlimited | select UserPrincipalName
      }

Again is going through the shared mailboxes.

How am I going to declare the list via CSV?
How are you running the script?
Through powershell ISE
Which ever way I run it it doesn't work.
ASKER CERTIFIED SOLUTION
Avatar of Vasil Michev (MVP)
Vasil Michev (MVP)
Flag of Bulgaria image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I did try it like that but I will try again now and I will let you know
Vasil both of these worked.

Thank you so much for your help! X  X  X
Vasil thank you for your help.
your comments helped me through and made it work for me
Greatly appreciated the time you spent!