Get-Mailboxpermission for list of Mailboxes

三世轮回 提交于 2019-12-08 01:26:08

问题


I want to get a list of all permissions for a specified list of mailboxes.

To get all permissions for just one, I can do this:

Get-MailboxPermission -Identity "Mailbox01"

What if I wanted to get a list of permissions for more than one mailbox at a time?

Something like:

Get-MailboxPermission -Identity "Mailbox01","Mailbox02","Mailbox03"

How could I do something like that - in one list?


回答1:


something like this should work:

"Mailbox01","Mailbox02","Mailbox03" | % { Get-MailboxPermission -Identity $_ }

Have to use a foreach because Get-MailboxPermission doesn't accept [string[]] as pipeline input or you can do:

"Mailbox01","Mailbox02","Mailbox03" | get-mailbox | Get-MailboxPermission



回答2:


You should first pull a list of the mailboxes needed and pipe into a variable or paste into a .CSV file (I prefer CSV files). Example:

Get-Mailbox -resultsize unlimited   | Where-Object {$_.RecipientType -like "UserMailbox"} | select userprincipalname, ForwardingAddress |out-gridview

$CSV = import-csv "c:\CSV.csv"

$CSV |out-gridview 

$CSV | foreach {get-MailboxPermission -identity $_.userprincipalname} |out-gridview

with the Gridview you can then further sort on multiple values



来源:https://stackoverflow.com/questions/18210923/get-mailboxpermission-for-list-of-mailboxes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!