每行一个不同的文件夹

时间:2015-01-19 15:57:49

标签: sorting powershell permissions directory exchange-server

我实际上列出了一些Exhange Mailboxes的文件夹,其中包含以下交换命令:

get-mailboxfolder -recurse | get-mailboxfolderpermissions | ft

现在输出如下:

RunspaceId                    FolderName                    User                          AccessRights                  Identity                                            IsValid
----------                    ----------                    ----                          ------------                  --------                                            -------
0a6a00b7-859a-4297-b03f-41... Top of Information Store      Default                       {None}                        Default                                                True
0a6a00b7-859a-4297-b03f-41... Top of Information Store      Anonymous                     {None}                        Anonymous                                              True
0a6a00b7-859a-4297-b03f-41... Calendar                      Default                       {AvailabilityOnly}            Default                                                True
0a6a00b7-859a-4297-b03f-41... Calendar                      Anonymous                     {None}                        Anonymous                                              True
0a6a00b7-859a-4297-b03f-41... Contacts                      Default                       {None}                        Default                                                True
0a6a00b7-859a-4297-b03f-41... Contacts                      Anonymous                     {None}                        Anonymous                                              True
0a6a00b7-859a-4297-b03f-41... Deleted Items                 Default                       {None}                        Default                                                True
0a6a00b7-859a-4297-b03f-41... Deleted Items                 Anonymous                     {None}                        Anonymous                                              True
0a6a00b7-859a-4297-b03f-41... Drafts                        Default                       {None}                        Default                                                True

如您所见,输出显示为每个设置的用户,一次是同一个文件夹。

我希望每个文件夹只有一行包含所有用户的列表。这样的事情:

RunspaceId                    FolderName                    User                          AccessRights                  Identity                                            IsValid
----------                    ----------                    ----                          ------------                  --------                                            -------
0a6a00b7-859a-4297-b03f-41... Top of Information Store      Default, Anonymous            {None}                        Default                                                True
0a6a00b7-859a-4297-b03f-41... Calendar                      Default, Anonymous            {AvailabilityOnly}            Default                                                True

1 个答案:

答案 0 :(得分:0)

这是你正在寻找的吗?您需要指定组合AccessRights,Identity等的处理方式。我做了一个示例,让您了解如何执行此操作,但如果您想添加额外的字段等,则需要修改。

我无法访问Get-MailboxFolderGet-MailboxFolderPermissions,因此输出结果是我认为的样子。我对AccessRights - 部分并不是100%肯定,因为我不知道数据类型。

$combinedUsers = @{n="Users";e={($_.Group | Select-Object -ExpandProperty User) -join ', '}}
$combinedAccessRights = @{n="AccessRights";e={($_.Group | Select-Object -ExpandProperty AccessRights) -join ', '}}

get-mailboxfolder -recurse |
get-mailboxfolderpermissions |
Group-Object FolderName |
Select-Object @{n="FolderName";e={$_.Name}}, $combinedUsers, $combinedAccessRights


FolderName                    Users                         AccessRights
----------                    ----                          ------------
Top of Information Store      Default, Anonymous            {None}, {None}
Calendar                      Default, Anonymous            {AvailabilityOnly}, {None}