Site icon Franky's Web

Exchange 2010/2013: Assigning permissions to folders and subfolders in a mailbox

Here is a small script that assigns permissions to folders and subfolders in a mailbox for users. Unfortunately, it is not yet possible to inherit permissions within a mailbox. So here is a small workaround:

<#
---------------------------------------------------------------------------------------
 
 www.frankysweb.de
 by Frank Zöchling

---------------------------------------------------------------------------------------
#>

$mailbox = read-host "Postfach"
$folder = read-host "Postfach Ordner"
$user = read-host "Benutzer"
$berechtigung = read-host "Berechtigung"

$folderpath = "$mailbox" + ":\" + "$folder"
$mailboxfolders = get-mailboxfolder $folderpath -recurse
foreach ($mailboxfolder in $mailboxfolders)
{
 $folderid = $mailboxfolder.Identity
 add-MailboxFolderPermission $folderid -user $user -AccessRights $berechtigung
}

Copy the script as usual into a PS1 file and execute it. Information on the possible permissions and a script that sets the permissions on an entire database can be found here:

https://www.frankysweb.de/exchange-2010-script-fr-berechtigungen-auf-postfach-ordner-einer-mailboxdatenbank/

Update:  Bei Exchange 2013 funktioniert der Befehl „get-mailboxfolder“ nicht mehr für andere Benutzer, daher hier eine Version des Scripts für Exchange 2013:

<#
---------------------------------------------------------------------------------------
  
 www.frankysweb.de
by Frank Zöchling

---------------------------------------------------------------------------------------
#>

$mailbox = read-host "Postfach"
$folder = read-host "Postfach Ordner"
$user = read-host "Benutzer"
$berechtigung = read-host "Berechtigung"

$mailboxfolders = Get-MailboxFolderStatistics $mailbox | Where {$_.FolderPath -match $folder}
foreach ($mailboxfolder in $mailboxfolders)
{
$folderid = $mailboxfolder.folderpath.replace("/","\")
$folderid = "$mailbox" + ":" + "$folderid"
Add-MailboxFolderPermission $folderid -User $user -AccessRights $berechtigung
}

Exit mobile version