问题
I have been working on a script to display permissions for all mailboxes at once, for a certain user at a time. Unfortunately, since the -Identity attribute in the Get-MailboxFolderPermission command doesn't accept wildcards, this is getting a bit complicated and messy.
I have started using an array to store all the mailboxes, so I can loop through it and run the command on each of them, but I've been unable to make this work because I haven't been able to reduce any of my outputs to just the email address. Here's my most recent iteration:
$Mailboxes = Get-Mailbox | Select Name -ExpandProperty EmailAddresses | Select AddressString
$MailboxList = @()
Foreach ($Box in $Mailboxes) {
$BoxName = Out-String -InputObject $Box
echo $BoxName | Out-File "box.txt"
$BoxName = Select-String "box.txt" -Pattern "\b[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}\b"
echo $BoxName
$MailboxList += $BoxName
}
The problem with this code is that the $BoxName variable comes back with "box.txt:4:" text attached to it. Attempts to remove that text with -Replace have resulted in a full filepath being added.
I'm fairly new to Powershell, so even if this is just the entirely wrong approach, I would appreciate some pointers on how to do what I'm trying to do here.
Thanks
回答1:
You could try to display permissions for all mailboxes using the below command:
Get-Mailbox -Resultsize unlimited | Get-MailboxPermission | Where { ($_.IsInherited -eq $False) -and -not ($_.User -like "NT AUTHORITY\SELF") } | Select Identity,user,AccessRights
For more information, Please refer to this link:
Get-MailboxPermission for multiple (all) users
来源:https://stackoverflow.com/questions/53559915/exchange-powershell-get-mailboxfolderpermission-for-all-calendars