SOLVED

Calendar permissions

%3CLINGO-SUB%20id%3D%22lingo-sub-850719%22%20slang%3D%22en-US%22%3ECalendar%20permissions%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-850719%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3EI%20am%20new%20in%20PowerShell%20so%20little%20help%20would%20be%20most%20appreciated.%3C%2FP%3E%3CP%3EI%20would%20need%20to%20use%20this%20cmdlet%3A%3C%2FP%3E%3CP%3E%3CEM%3E%3CSTRONG%3EGet-MailboxFolderPermission%20-Identity%20john%40contoso.com%3A%5CCalendar%20-User%20Ayla%40contoso.com%3C%2FSTRONG%3E%3C%2FEM%3E%3C%2FP%3E%3CP%3Ebut%20instead%20of%20one%20user%20I%20need%20it%20to%20work%20for%20whole%20domain%20(all%20users%20that%20have%20%40contoso.com%20as%20example).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAny%20idea%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EKind%20regards%2C%3C%2FP%3E%3CP%3EDino%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-850719%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EOffice%20365%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EWindows%20PowerShell%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-851077%22%20slang%3D%22en-US%22%3ERe%3A%20Calendar%20permissions%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-851077%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F390770%22%20target%3D%22_blank%22%3E%40DiVojich%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20would%20suggest%20to%20do%20the%20following%3A%3C%2FP%3E%3COL%3E%3CLI%3EGet%20all%20mailboxes%20with%20the%20cmdlet%20Get-Mailbox%20(%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fmodule%2Fexchange%2Fmailboxes%2Fget-mailbox%3Fview%3Dexchange-ps%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3Elink%3C%2FA%3E)%3C%2FLI%3E%3CLI%3EIterate%20through%20each%20mailbox%20to%20get%20the%20mailbox%20folder%20permissions%3C%2FLI%3E%3C%2FOL%3E%3CP%3EFor%20more%20information%20on%20iterating%20through%20an%20output%2C%20please%20use%20the%20documentation%20for%20the%20command%20ForEach-Object%20(%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fmodule%2Fmicrosoft.powershell.core%2Fforeach-object%3Fview%3Dpowershell-6%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3Elink%3C%2FA%3E).%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-852727%22%20slang%3D%22en-US%22%3ERe%3A%20Calendar%20permissions%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-852727%22%20slang%3D%22en-US%22%3E%3CP%3Ethis%20should%20work%3A-%3CBR%20%2F%3E%3CBR%20%2F%3E%24mailboxes%3DGet-Mailbox%7C%3F%7B%24_.PrimarySMTPAddress%20-match%20%22%40contoso.com%22%7D%3CBR%20%2F%3E%3CBR%20%2F%3Eforeach%20(%24mailbox%20in%20%24mailboxes)%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%24SMTP%3D%24mailbox.PrimarySMTPAddress%3CBR%20%2F%3E%24calendar%3D%24SMTP%2B%22%3A%5CCalendar%22%3CBR%20%2F%3EGet-MailboxFolderPermission%20%24calendar%20-User%26nbsp%3BAyla%40contoso.com%3CBR%20%2F%3E%7D%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-853854%22%20slang%3D%22en-US%22%3ERe%3A%20Calendar%20permissions%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-853854%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F333418%22%20target%3D%22_blank%22%3E%40DeepakRandhawa%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3Ea%20couple%20of%20questions...where%20should%20I%20put%20%22ResultSize%20-Unlimited%22%2C%20I%20presume%20in%20Get-Mailbox%201st%20line%3F%3C%2FP%3E%3CP%3EWhy%20is%20for%20user%20saying%20%22Deafult%22%20%26amp%3B%20not%20giving%20me%20names%20of%20actual%20users%3F%3C%2FP%3E%3CP%3EAlso%2C%20calendar%20does%20not%20show%20the%20identities%20to%20the%20which%20the%20permissions%20apply....%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EKind%20regards%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F131642i8324DD45D3D56FF1%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22powerShell%20calendar.png%22%20title%3D%22powerShell%20calendar.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-853986%22%20slang%3D%22en-US%22%3ERe%3A%20Calendar%20permissions%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-853986%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F390770%22%20target%3D%22_blank%22%3E%40DiVojich%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20have%20to%20use%20%22-ResultSize%20Unlimited%22%20with%20Get-Mailbox%20cmdlet%3C%2FP%3E%3CPRE%3EGet-Mailbox%20-ResultSize%20Unlimited%3C%2FPRE%3E%3CP%3EYou%20have%20to%20exclude%20the%20parameter%20%22-User%20Default%22%20to%20list%20all%20user%20permissions%20in%20John's%20mailbox.%20If%20you%20provide%20%22-User%22%20parameter%2C%20then%20the%20command%20list%20only%20permission%20entries%20for%20the%20specific%20user%20in%20John's%20mailbox.%20The%20below%20command%20list%20all%20users%20who%20has%20permission%20in%26nbsp%3BJohn's%20mailbox%20calendar.%3C%2FP%3E%3CPRE%3EGet-MailboxFolderPermission%20-Identity%20john%40contoso.com%3A%5CCalendar%3C%2FPRE%3E%3CP%3EThe%20below%20command%20lists%20all%20users%20permission%20entries%20in%20all%20users%20mailbox%26nbsp%3Bcalendar.%3C%2FP%3E%3CPRE%3EGet-Mailbox%20-ResultSize%20Unlimited%20%7C%20ForEach%20%7BGet-MailboxFolderPermission%20-Identity%20%22%24(%24_.PrimarySMTPAddress)%3A%5CCalendar%22%20%7D%20%7C%20Select%20Identity%2CUser%2CAccessRights%3C%2FPRE%3E%3CP%3EYou%20can%20exclude%20the%20%22Default%22%20%26amp%3B%20%22Anonymous%22%20entries%20with%20Where-Object%20filter%3C%2FP%3E%3CPRE%3EGet-Mailbox%20-ResultSize%20Unlimited%20%7C%20ForEach%20%7BGet-MailboxFolderPermission%20-Identity%20%22%24(%24_.PrimarySMTPAddress)%3A%5CCalendar%22%20%7D%20%7C%20Where-Object%20%7B%24_.User.DisplayName%20-ne%20%22Default%22%20-and%20%24_.User.DisplayName%20-ne%20%22Anonymous%22%7D%20%7C%20Select%20Identity%2CUser%2CAccessRights%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20847px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F131663iF438D600DB4C6F36%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22mailbox-calendar-permissions.png%22%20title%3D%22mailbox-calendar-permissions.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-854033%22%20slang%3D%22en-US%22%3ERe%3A%20Calendar%20permissions%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-854033%22%20slang%3D%22en-US%22%3E%3CP%3EHi%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F390770%22%20target%3D%22_blank%22%3E%40DiVojich%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eplease%20have%20a%20look%20again%20at%20the%20documentation%20for%20the%20cmdlets%20of%20Get-Mailbox%20(%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fmodule%2Fexchange%2Fmailboxes%2Fget-mailbox%3Fview%3Dexchange-ps%23examples%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3Elink%3C%2FA%3E)%20and%20Get-MailboxFolderPermission%20(%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fmodule%2Fexchange%2Fmailboxes%2Fget-mailboxfolderpermission%3Fview%3Dexchange-ps%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3Elink%3C%2FA%3E).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20you%20want%20to%20get%20all%20mailboxes%20in%20your%20organization%2C%20you%20need%20to%20use%20the%20following%20code%3A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-csharp%22%3E%3CCODE%3EGet-Mailbox%20-ResultSize%20unlimited%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3BIf%20you%20want%20to%20get%20the%20calendar%20permission%20of%20each%20mailbox%20use%20the%20following%3A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-csharp%22%3E%3CCODE%3EGet-Mailbox%20-ResultSize%20unlimited%20%7C%20%25%20%7BGet-MailboxFolderPermission%20-Identity%20(%24_.alias%20%2B%20%22%3A%5CCalendar%22)%20%7C%20select%20User%2CFoldername%2CAccessRight%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-854255%22%20slang%3D%22en-US%22%3ERe%3A%20Calendar%20permissions%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-854255%22%20slang%3D%22en-US%22%3Eyou%20are%20correct%20%22ResultSize%20-Unlimited%22%20goes%20here%3CBR%20%2F%3E%24mailboxes%3DGet-Mailbox%20-ResultSize%20Unlimited%20%7C%3F%7B%24_.PrimarySMTPAddress%20-match%20%22%40contoso.com%22%7D%3CBR%20%2F%3E%3CBR%20%2F%3EFor%20all%20permissions%20on%20a%20calendar%20simply%20remove%20%22-User%20Ayla%40contoso.com%22%20part%20of%20the%20command.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-870195%22%20slang%3D%22en-US%22%3ERe%3A%20Calendar%20permissions%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-870195%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F333418%22%20target%3D%22_blank%22%3E%40DeepakRandhawa%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20is%20what%20worked%20from%20me%2C%20after%20some%20tweaking%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CDIV%3E%24Report%20%3D%20ForEach%20(%24Mailbox%20in%20(Get-Mailbox%20-ResultSize%20Unlimited%20-RecipientType%20UserMailbox%20%7C%20Where-Object%20%7B(%24_.WindowsEmailAddress%20-like%20'*%40%22insert_domain_name%22*')%7D))%3CBR%20%2F%3E%7B%20Get-MailboxFolderPermission%20-Identity%20%22%24(%24Mailbox.Name)%3A%5CCalendar%22%20%7C%20Select%20%40%7Bn%3D'Mailbox'%3Be%3D%7B%24Mailbox.Name%7D%7D%2CUser%2CAccessRights%7D%3CBR%20%2F%3Eout-file%20-filepath%20C%3A%5CExport.txt%20-inputobject%20%24report%3C%2FDIV%3E%3C%2FLINGO-BODY%3E
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