Sep 12 2019 01:55 AM
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
Sep 12 2019 03:44 AM
Sep 12 2019 09:31 AM - edited Sep 12 2019 09:32 AM
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
}
Sep 12 2019 10:36 PM - edited Sep 12 2019 11:30 PM
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,
Sep 13 2019 12:05 AM - edited Sep 13 2019 12:07 AM
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
Sep 13 2019 12:23 AM
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
Sep 13 2019 04:05 AM
Sep 23 2019 06:03 AM
SolutionThis is what worked from me, after some tweaking
Sep 23 2019 06:03 AM
SolutionThis is what worked from me, after some tweaking