Forum Discussion

DiVojich's avatar
DiVojich
Copper Contributor
Sep 12, 2019
Solved

Calendar permissions

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

  • DiVojich's avatar
    DiVojich
    Sep 23, 2019

    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

7 Replies

  • 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
    }

    • DiVojich's avatar
      DiVojich
      Copper Contributor

      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,

       

      • DeepakRandhawa's avatar
        DeepakRandhawa
        Iron Contributor
        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.
  • ClaudioCerchia's avatar
    ClaudioCerchia
    Copper Contributor

    Hi DiVojich 

    I would suggest to do the following:

    1. Get all mailboxes with the cmdlet Get-Mailbox (https://docs.microsoft.com/en-us/powershell/module/exchange/mailboxes/get-mailbox?view=exchange-ps)
    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 (https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/foreach-object?view=powershell-6).

Resources