SOLVED

Calendar permissions

Contributor

Hi,

I am new in PowerShell so little help would be most appreciated.

I would need to use this cmdlet:

Get-MailboxFolderPermission -Identity john@contoso.com:\Calendar -User Ayla@contoso.com

but instead of one user I need it to work for whole domain (all users that have @contoso.com as example).

 

Any idea?

 

Kind regards,

Dino

7 Replies

Hi @DiVojich 

I would suggest to do the following:

  1. Get all mailboxes with the cmdlet Get-Mailbox (link)
  2. Iterate through each mailbox to get the mailbox folder permissions

For more information on iterating through an output, please use the documentation for the command ForEach-Object (link).

this should work:-

$mailboxes=Get-Mailbox|?{$_.PrimarySMTPAddress -match "@contoso.com"}

foreach ($mailbox in $mailboxes)
{
$SMTP=$mailbox.PrimarySMTPAddress
$calendar=$SMTP+":\Calendar"
Get-MailboxFolderPermission $calendar -User Ayla@contoso.com
}

@DeepakRandhawa 

Hi,

a couple of questions...where should I put "ResultSize -Unlimited", I presume in Get-Mailbox 1st line?

Why is for user saying "Deafult" & not giving me names of actual users?

Also, calendar does not show the identities to the which the permissions apply....

 

Kind regards,

 

powerShell calendar.png

@DiVojich 

 

You have to use "-ResultSize Unlimited" with Get-Mailbox cmdlet

Get-Mailbox -ResultSize Unlimited

You have to exclude the parameter "-User Default" to list all user permissions in John's mailbox. If you provide "-User" parameter, then the command list only permission entries for the specific user in John's mailbox. The below command list all users who has permission in John's mailbox calendar.

Get-MailboxFolderPermission -Identity john@contoso.com:\Calendar

The below command lists all users permission entries in all users mailbox calendar.

Get-Mailbox -ResultSize Unlimited | ForEach {Get-MailboxFolderPermission -Identity "$($_.PrimarySMTPAddress):\Calendar" } | Select Identity,User,AccessRights

You can exclude the "Default" & "Anonymous" entries with Where-Object filter

Get-Mailbox -ResultSize Unlimited | ForEach {Get-MailboxFolderPermission -Identity "$($_.PrimarySMTPAddress):\Calendar" } | Where-Object {$_.User.DisplayName -ne "Default" -and $_.User.DisplayName -ne "Anonymous"} | Select Identity,User,AccessRights

 mailbox-calendar-permissions.png

Hi@DiVojich 

 

please have a look again at the documentation for the cmdlets of Get-Mailbox (link) and Get-MailboxFolderPermission (link).

 

If you want to get all mailboxes in your organization, you need to use the following code:

Get-Mailbox -ResultSize unlimited

 If you want to get the calendar permission of each mailbox use the following:

Get-Mailbox -ResultSize unlimited | % {Get-MailboxFolderPermission -Identity ($_.alias + ":\Calendar") | select User,Foldername,AccessRight

 

you are correct "ResultSize -Unlimited" goes here
$mailboxes=Get-Mailbox -ResultSize Unlimited |?{$_.PrimarySMTPAddress -match "@contoso.com"}

For all permissions on a calendar simply remove "-User Ayla@contoso.com" part of the command.
best response confirmed by DiVojich (Contributor)
Solution

@DeepakRandhawa 

This is what worked from me, after some tweaking

 

$Report = ForEach ($Mailbox in (Get-Mailbox -ResultSize Unlimited -RecipientType UserMailbox | Where-Object {($_.WindowsEmailAddress -like '*@"insert_domain_name"*')}))
{ Get-MailboxFolderPermission -Identity "$($Mailbox.Name):\Calendar" | Select @{n='Mailbox';e={$Mailbox.Name}},User,AccessRights}
out-file -filepath C:\Export.txt -inputobject $report