Add manager “reviewer” access to employee’s calendar

June 24, 2020 | by iaur | posted as Calendaring, Exchange Online

Scenarios

  • You want to give supervisors access to their subordinates calendar items.

Requisites

  • Global admin account and  break-glass version or non MFA enabled
  •  PowerShell ISE on Windows

Note

  • Line 6: $userRequiringAccess = “manageralias@customdomain.com” is the manager that needs access
  • Line 7: $accessRight = “Reviewer”  is the control variable that defines what access level that manager will have

Steps

  • Download and save the attachment:

Code:

$credential = Get-Credential   $Session = New-PSSession -ConnectionUri "https://outlook.office365.com/powershell-liveid/" -ConfigurationName Microsoft.Exchange -Credential $credential -Authentication Basic -AllowRedirection Import-PSSession $Session   $userRequiringAccess = "manageralias@customdomain.com" $accessRight = "Reviewer"   $mailboxes = Get-mailbox $userRequiringAccess = Get-mailbox $userRequiringAccess foreach ($mailbox in $mailboxes) {     $accessRights = $null     $accessRights = Get-MailboxFolderPermission "$($mailbox.primarysmtpaddress):\calendar" -User $userRequiringAccess.PrimarySmtpAddress -erroraction SilentlyContinue              if ($accessRights.accessRights -notmatch $accessRight -and $mailbox.primarysmtpaddress -notcontains $userRequiringAccess.primarysmtpaddress -and $mailbox.primarysmtpaddress -notmatch "DiscoverySearchMailbox") {         Write-Host "Adding or updating permissions for $($mailbox.primarysmtpaddress) Calendar" -ForegroundColor Yellow         try {             Add-MailboxFolderPermission "$($mailbox.primarysmtpaddress):\calendar" -User $userRequiringAccess.PrimarySmtpAddress -AccessRights $accessRight -ErrorAction SilentlyContinue            }         catch {             Set-MailboxFolderPermission "$($mailbox.primarysmtpaddress):\calendar" -User $userRequiringAccess.PrimarySmtpAddress -AccessRights $accessRight -ErrorAction SilentlyContinue            }                $accessRights = Get-MailboxFolderPermission "$($mailbox.primarysmtpaddress):\calendar" -User $userRequiringAccess.PrimarySmtpAddress         if ($accessRights.accessRights -match $accessRight) {             Write-Host "Successfully added $accessRight permissions on $($mailbox.displayname)'s calendar for $($userrequiringaccess.displayname)" -ForegroundColor Green         }         else {             Write-Host "Could not add $accessRight permissions on $($mailbox.displayname)'s calendar for $($userrequiringaccess.displayname)" -ForegroundColor Red         }     }else{         Write-Host "Permission level already exists for $($userrequiringaccess.displayname) on $($mailbox.displayname)'s calendar" -foregroundColor Green     } } Remove-PSSession $Session
  • Open with PoweShell ISE and modify according to the Note section
  • Press the play button once done
  • Follow the admin authentication prompt and supply appropriate credentials
  • Finally, you’ll have this kind of progress screen. Wait for it to complete before testing
Machine generated alternative text:
Adding or updati ng 
Cal endar 
Successfully added 
Adding or updati ng 
Cal endar 
Successfully added 
permi ssions for userlafaceresionem.xyz Calendar 
Jul 
{Revi ewer} 
Revi ewer permissions on user I's calendar for Jul 
permi ssions for usernfaceresionem.xyz Calendar 
Jul 
{Revi ewer} 
Revi ewer permissions on user 2 's calendar for Jul 
PS C: I

Feedback or Help?

Should you have one, click here

Boring Ads. Pardon me :)