Home > Software engineering >  How do I change the permissions of a user for 600 folders in Outlook via PowerShell?
How do I change the permissions of a user for 600 folders in Outlook via PowerShell?

Time:11-04

I'm trying to give an assistant access to part of someone's O365 mailbox. She currently has foldervisible permissions on his inbox. And there is about 607 folders under the inbox that she needs access to without having anymore permissions to the inbox itself.

Below is the code I've tried to run. I've removed the domain name but otherwise the code is exact. I've run the code twice and gotten no errors and it runs for a quite a while. But once it's complete, there is no change in the permissions.

ForEach($f in (Get-EXOMailboxFolderStatistics -identity jjo | Where { $_.FolderPath.Contains("jjo:/Inbox/Case Files") -eq $True } ) ) {
     $fname = "jjo:"   $f.FolderPath.Replace("/","\");
     Add-MailboxFolderPermission $fname -User gka -AccessRights Owner 
}

CodePudding user response:

Try to narrow down what's working and not;

Get-EXOMailboxFolderStatistics -identity jjo -ErrorAction Stop | Where-Object { $_.FolderPath.Contains("jjo:/Inbox/Case Files") } | ForEach-Object {
     Try {
        $fname = "jjo:"   $_.FolderPath.Replace("/","\")
        Write-Host "Amending: $fname ..."
        Add-MailboxFolderPermission $fname -User gka -AccessRights Owner -ErrorAction Stop
        Write-Host "Done"
     }
     Catch {
        $_
     }
}
Write-Host "Complete"

CodePudding user response:

On the client side, Extended MAPI (C or Delphi) can be used modify the ACL table on the folder level. If using Redemption (I am its author) is an option (any language), you can use RDOFolder.ACL collection to modify the permissions. Something along the lines (VBA, off the op of my head):

ROLE_PUBLISH_EDITOR = &H4FB
set Session = CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
set AddressEntry = Session.AddressBook.GAL.ResolveName("The Other User Name")
set Folder = Session.GetDefaultFolder(olFolderInbox)
for each subFolder in Folder.Folders
  set ACE = subFolder.ACL.Add(AddressEntry)
  ACE.Rights = ROLE_PUBLISH_EDITOR
next  
  • Related