Dear Ladies and Gentleman
Iam Trying to complete my task with the following code and situation.
A user has a lot of folders in his mailbox. Some of them should be shared with other users from the same domain.
With the actual code which should work, i actually don`t get the goal. I also don't get any Errors in Powershell ISE.
But the Permission will ne be set.
Does somebody can help me in this situation?
$requiredfoldertypes = @("Posteingang_LOKAL\DLR","Posteingang_LOKAL\Eisele Carport Esslingen","Posteingang_LOKAL\Gewürz Mayer","Posteingang_LOKAL\Regner Klinikum St. Marien Amberg ")
$excludedfoldertypes = @()
$accessright = “Reviewer"
$users = @("Kretschmer@contoso") #,"******@contoso.com")
$mbx = Get-EXOMailbox -Identity ******@contoso.com | Select-Object PrimarySmtpAddress
$folderlist = Get-EXOMailboxFolderStatistics -Identity $mbx.PrimarySmtpAddress | Select-Object Name, FolderPath, FolderType, Identity | ?{($_.FolderType -in $requiredfoldertypes) -and ($_.FolderType -notin $requiredfoldertypes) }
#Then we can use either Add-MailboxFolderPermission to assign or Set-MailboxFolderPermission to modify.
foreach($user in $users)
{
$u = Get-EXOMailbox -Identity $user | Select-Object PrimarySmtpAddress
foreach($folder in $folderlist)
{
if($folder.FolderType -eq "Root") {$foldername = $mbx }
else {$foldername = $folder.Identity.ToString().Replace([char]63743,"/").Replace($mbx.PrimarySmtpAddress.ToString(),$mbx.PrimarySmtpAddress.ToString() + ":")}
$foldername
Add-MailboxFolderPermission -Identity $foldername -User $u.PrimarySmtpAddress.Tostring() -AccessRights $accessright
Get-MailboxFolderPermission -Identity $foldername -User $u.PrimarySmtpAddress.Tostring()
}
}
Oviously the follow command works like a charm but without inheritance.
$mailbox = "******@contos.com"
$user = "******@comtoso.com" $foldername = "Posteingang_LOKAL\AMG Erweiterung Vormontage LZM-Marbach"
$folder = (Get-EXOMailboxFolderStatistics -Identity "$($mailbox)" | Where-Object { $_.FolderType -eq "Posteingang_LOKAL" }).Name
Add-MailboxFolderPermission "$($mailbox):$($folder)\$($foldername)" -User "$($user)" -AccessRights "Reviewer" | Select-Object FolderName, User, AccessRights
Maybe somebody had already the problem and could help me?
Kind Reagrds.