每行一个不同的文件夹

One different Folder per Line

我实际上使用以下交换命令列出了一些 Exchange 邮箱的文件夹权限:

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

这是您要找的吗?您需要指定您希望如何处理 AccessRights、Identity 等的组合。我制作了一个示例来让您了解如何执行此操作,但如果您想添加额外的字段等,则需要进行修改。

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

$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}