Hello,
I need an exchange management shell script to give all users with full access on mailboxes 'reviewer' accessrights on the 'Inbox' of the corresponding folder.
For now I've created this for my testcase:
$mailboxes = Get-Mailbox -identity gp -ResultSize Unlimited -Filter ('RecipientTypeDetails -eq "UserMailbox"')
foreach ($mailbox in $mailboxes)
{
$Permissions =
Get-MailboxPermission -Identity $mailbox.alias -ResultSize Unlimited |
?{($.IsInherited -eq $false) -and
($.User -ne "NT AUTHORITY\SELF") -and
($_.AccessRights -like "FullAccess")} | select Identity, User, AccessRights
foreach ($Permission in $Permissions) {
Add-MailboxFolderPermission -Identity "$($mailbox.Alias):\Inbox" -User $Permission.user -AccessRights Reviewer
Add-MailboxFolderPermission -Identity "$($mailbox.Alias):\Postvak IN" -User $Permission.user -AccessRights Reviewer
}
}
This works in Exchange Online Powershell, but it fails on the on premise exchange 2016 server with the following error:
Cannot convert the "domain\username" value of type "Microsoft.Exchange.Configuration.Tasks.SecurityPrincipalIdParameter" to type "Microsoft.Exchange.Management.StoreTasks.MailboxFolderUserIdParameter"
I believe this may be due to an incorrect loop.
Can someone help me with this?