Forum Discussion
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
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
- DeepakRandhawaIron Contributor
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
}- DiVojichCopper Contributor
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,
- DeepakRandhawaIron Contributoryou 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.
- ClaudioCerchiaCopper Contributor
Hi DiVojich
I would suggest to do the following:
- Get all mailboxes with the cmdlet Get-Mailbox (https://docs.microsoft.com/en-us/powershell/module/exchange/mailboxes/get-mailbox?view=exchange-ps)
- 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).