Skip to content

Commit 2b92fa3

Browse files
authored
v2.3.1 (#22)
## <a href="https://github.com/GruberMarkus/Export-RecipientPermissions/releases/tag/v2.3.1" target="_blank">v2.3.1</a> - 2022-11-28 ### Added - New FAQ in '`README`': 'How to export permissions for specific public folders?' ### Fixed - Sample code '`compare.ps1`' now additionally outputs the original identity of a trustee and not only the primary SMTP address. This helps with permissions granted to 'Anonymous' and 'Default', as well as with recipients which have been deleted in the time between the old and the new export. - Always include trustee groups in '`GrantorFilter`' when '`ExportDistributionGroups`' is set to '`OnlyTrustees`'
1 parent 2c8284c commit 2b92fa3

File tree

6 files changed

+105
-11
lines changed

6 files changed

+105
-11
lines changed

.github/workflows/build, draft release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ jobs:
1515
fetch-depth: 0
1616

1717
- name: Install GitVersion
18-
uses: gittools/actions/gitversion/[email protected].14
18+
uses: gittools/actions/gitversion/[email protected].15
1919
with:
2020
versionSpec: "5.x"
2121

2222
- name: Determine SemVer
23-
uses: gittools/actions/gitversion/[email protected].14
23+
uses: gittools/actions/gitversion/[email protected].15
2424
with:
2525
additionalArguments: '/overrideconfig major-version-bump-message="^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\\([\\w\\s]*\\))?(!:|:.*\\n\\n((.+\\n)+\\n)?BREAKING CHANGE:\\s.+)" /overrideconfig minor-version-bump-message="^(feat)(\\([\\w\\s]*\\))?:" /overrideconfig patch-version-bump-message="^(build|chore|ci|docs|fix|perf|refactor|revert|style|test)(\\([\\w\\s]*\\))?:"'
2626

build/build.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ function main {
5858
$tempFileContent = $tempFileContent -replace 'XXXRemoveWhenBuildingXXX-->', ''
5959
$tempFileContent | Set-Content $($_[0])
6060
# convert to HTML
61-
& pandoc.exe $($_[0]) --resource-path=".;docs" -f gfm -t html --self-contained -H .\build\pandoc_header.html --css .\build\pandoc_css_empty.css --metadata pagetitle="$(([System.IO.FileInfo]"$($_[0])").basename) - $(($env:GITHUB_REPOSITORY -split '/')[1])" -o $($_[1])
61+
& pandoc.exe $($_[0]) --resource-path=".;docs" -f gfm -t html --embed-resources --standalone -H .\build\pandoc_header.html --css .\build\pandoc_css_empty.css --metadata pagetitle="$(([System.IO.FileInfo]"$($_[0])").basename) - $(($env:GITHUB_REPOSITORY -split '/')[1])" -o $($_[1])
6262
}
6363

6464

docs/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@
1515
### Fixed
1616
-->
1717

18+
## <a href="https://github.com/GruberMarkus/Export-RecipientPermissions/releases/tag/v2.3.1" target="_blank">v2.3.1</a> - 2022-11-28
19+
### Added
20+
- New FAQ in '`README`': 'How to export permissions for specific public folders?'
21+
### Fixed
22+
- Sample code '`compare.ps1`' now additionally outputs the original identity of a trustee and not only the primary SMTP address. This helps with permissions granted to 'Anonymous' and 'Default', as well as with recipients which have been deleted in the time between the old and the new export.
23+
- Always include trustee groups in '`GrantorFilter`' when '`ExportDistributionGroups`' is set to '`OnlyTrustees`'
24+
1825
## <a href="https://github.com/GruberMarkus/Export-RecipientPermissions/releases/tag/v2.3.0" target="_blank">v2.3.0</a> - 2022-10-25
1926
### Added
2027
- When '`ExportFromOnPrem`' is set to '`$true`' and '`ExchangeConnectionUriList`' is not specified, '`ExchangeConnectionUriList`' defaults to '`http://<server>/powershell`' for each Exchange server with the mailbox server role

docs/README.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ Compare exports from different times to detect permission changes (sample code i
7676
- [2.9. Is there a GUI available?](#29-is-there-a-gui-available)
7777
- [2.10. Which resources does a particular user or group have access to?](#210-which-resources-does-a-particular-user-or-group-have-access-to)
7878
- [2.11. How to find distribution lists without members?](#211-how-to-find-distribution-lists-without-members)
79+
- [2.11.1. How to export permissions for specific public folders?](#2111-how-to-export-permissions-for-specific-public-folders)
7980
- [3. Sample code](#3-sample-code)
8081
- [3.1. Get-DependentRecipients.ps1](#31-get-dependentrecipientsps1)
8182
- [3.2. Compare-RecipientPermissions.ps1](#32-compare-recipientpermissionsps1)
@@ -705,6 +706,76 @@ $params = @{
705706
}
706707

707708

709+
& .\Export-RecipientPermissions\Export-RecipientPermissions.ps1 @params
710+
```
711+
### 2.11.1. How to export permissions for specific public folders?
712+
You need three things for this:
713+
- GrantorFilter should only include Public Folder Mailboxes
714+
- ExportFileFilter needs to remove everything not of interest
715+
716+
The following example shows how to export permissions granted on the public folder '/X', '/Y' and their subfolders, plus all members of groups granted permissions:
717+
```
718+
$params = @{
719+
ExportFromOnPrem = $true
720+
UseDefaultCredential = $true
721+
722+
ExportMailboxAccessRights = $false
723+
ExportMailboxAccessRightsSelf = $false
724+
ExportMailboxAccessRightsInherited = $false
725+
ExportMailboxFolderPermissions = $false
726+
ExportMailboxFolderPermissionsAnonymous = $true
727+
ExportMailboxFolderPermissionsDefault = $true
728+
ExportMailboxFolderPermissionsOwnerAtLocal = $true
729+
ExportMailboxFolderPermissionsMemberAtLocal = $true
730+
ExportSendAs = $false
731+
ExportSendAsSelf = $false
732+
ExportSendOnBehalf = $true
733+
ExportManagedBy = $false
734+
ExportLinkedMasterAccount = $false
735+
ExportPublicFolderPermissions = $true
736+
ExportPublicFolderPermissionsAnonymous = $true
737+
ExportPublicFolderPermissionsDefault = $true
738+
ExportForwarders = $false
739+
ExportManagementRoleGroupMembers = $false
740+
ExportDistributionGroupMembers = 'OnlyTrustees'
741+
ExportGroupMembersRecurse = $true
742+
ExpandGroups = $false
743+
ExportGuids = $true
744+
ExportGrantorsWithNoPermissions = $true
745+
ExportTrustees = 'All'
746+
747+
RecipientProperties = @()
748+
GrantorFilter = "if ( (`$Grantor.RecipientTypeDetails.Value -ieq 'PublicFolderMailbox') ) { `$true } else { `$false }"
749+
TrusteeFilter = $null
750+
ExportFileFilter = "
751+
if (
752+
(
753+
(`$ExportFileLine.'Grantor Recipient Type' -ieq 'UserMailbox/PublicFolderMailbox') -and
754+
(
755+
(`$ExportFileLine.'Folder' -ieq '/X') -or
756+
(`$ExportFileLine.'Folder' -ilike '/X/*') -or
757+
(`$ExportFileLine.'Folder' -ieq '/Y') -or
758+
(`$ExportFileLine.'Folder' -ilike '/Y/*')
759+
)
760+
) -or
761+
(
762+
`$ExportFileLine.'Grantor Recipient Type' -ine 'UserMailbox/PublicFolderMailbox'
763+
)
764+
) {
765+
`$true
766+
} else {
767+
`$false
768+
}
769+
"
770+
771+
ExportFile = '..\export\Export-RecipientPermissions_Result.csv'
772+
ErrorFile = '..\export\Export-RecipientPermissions_Error.csv'
773+
DebugFile = ''
774+
775+
verbose = $true
776+
}
777+
778+
708779
& .\Export-RecipientPermissions\Export-RecipientPermissions.ps1 @params
709780
```
710781
# 3. Sample code

src/Export-RecipientPermissions.ps1

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6423,6 +6423,10 @@ try {
64236423
if ($AllGroupMembers.ContainsKey($AllRecipients[$x].Identity.ObjectGuid.Guid)) {
64246424
$tempQueue.enqueue($x)
64256425
}
6426+
6427+
if (($ExportDistributionGroupMembers -ieq 'OnlyTrustees') -and (($x -notin $GrantorsToConsider))) {
6428+
$null = $GrantorsToConsider.add($x) # makes $ExportGrantorsWithNoPermissions work for these groups
6429+
}
64266430
}
64276431
}
64286432
}
@@ -7085,8 +7089,21 @@ try {
70857089
$tempQueue = [System.Collections.Queue]::Synchronized([System.Collections.Queue]::new($AllRecipients.count))
70867090

70877091
foreach ($x in $GrantorsToConsider) {
7088-
$tempQueue.enqueue($x)
7092+
if (($AllRecipients[$x].RecipientTypeDetails.Value -ilike 'Group*') -or ($AllRecipients[$x].RecipientTypeDetails.Value -ilike '*Group')) {
7093+
if ($ExportDistributionGroupMembers -ieq 'None') {
7094+
# do nothing
7095+
} elseif ($ExportDistributionGroupMembers -ieq 'OnlyTrustees') {
7096+
if ($AllRecipients[$x].IsTrustee -eq $true) {
7097+
$tempQueue.enqueue($x)
7098+
}
7099+
} else {
7100+
$tempQueue.enqueue($x)
7101+
}
7102+
} else {
7103+
$tempQueue.enqueue($x)
7104+
}
70897105
}
7106+
70907107
$tempQueueCount = $tempQueue.count
70917108

70927109
$ParallelJobsNeeded = [math]::min($tempQueueCount, $ParallelJobsLocal)

src/sample code/Compare-RecipientPermissions/Compare-RecipientPermissions.ps1

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,11 @@ Param(
2121
$newCsv = '.\Export-RecipientPermissions_Output_new.csv',
2222

2323
# Display results on screen before creating file showing changes
24-
$DisplayResults = $false,
25-
24+
$DisplayResults = $true,
2625

2726
# Path for export file showing changes
2827
# Set to '' or $null to not create this file
29-
$ChangeFile = '.\changes.csv'
28+
$ChangeFile = '.\comparison.csv'
3029
)
3130

3231

@@ -91,11 +90,11 @@ if ($DisplayResults) {
9190
Write-Host " $($GrantorPrimarySmtp)"
9291
foreach ($DatasetObject in $Dataset[$($GrantorPrimarySmtpOrder.IndexOf($GrantorPrimarySmtp))..$($GrantorPrimarySmtpReverseOrder.count - 1 - $GrantorPrimarySmtpReverseOrder.IndexOf($GrantorPrimarySmtp))]) {
9392
if ($DatasetObject.Change -eq 'Deleted') {
94-
Write-Host (" Deleted: $($DatasetObject.'Trustee Primary SMTP') no longer has the '$($DatasetObject.'Permission')' right" + $(if ($DatasetObject.'Folder') { " on folder '$($DatasetObject.'Folder')'" }))
93+
Write-Host (" Deleted: '$($DatasetObject.'Trustee Original Identity')' (E-Mail '$($DatasetObject.'Trustee Primary SMTP')') no longer has the '$($DatasetObject.'Permission')' right" + $(if ($DatasetObject.'Folder') { " on folder '$($DatasetObject.'Folder')'" }))
9594
} elseif ($DatasetObject.change -eq 'New') {
96-
Write-Host (" New: $($DatasetObject.'Trustee Primary SMTP') now has the '$($DatasetObject.'Permission')' right" + $(if ($DatasetObject.'Folder') { " on folder '$($DatasetObject.'Folder')'" }))
95+
Write-Host (" New: '$($DatasetObject.'Trustee Original Identity')' (E-Mail '$($DatasetObject.'Trustee Primary SMTP')) now has the '$($DatasetObject.'Permission')' right" + $(if ($DatasetObject.'Folder') { " on folder '$($DatasetObject.'Folder')'" }))
9796
} else {
98-
Write-Host (" Unchanged: $($DatasetObject.'Trustee Primary SMTP') still has the '$($DatasetObject.'Permission')' right" + $(if ($DatasetObject.'Folder') { " on folder '$($DatasetObject.'Folder')'" }))
97+
Write-Host (" Unchanged: '$($DatasetObject.'Trustee Original Identity')' (E-Mail '$($DatasetObject.'Trustee Primary SMTP')') still has the '$($DatasetObject.'Permission')' right" + $(if ($DatasetObject.'Folder') { " on folder '$($DatasetObject.'Folder')'" }))
9998
}
10099
}
101100
}
@@ -115,4 +114,4 @@ if ($ChangeFile) {
115114

116115

117116
Write-Host
118-
Write-Host "End script @$(Get-Date -Format 'yyyy-MM-ddTHH:mm:sszzz')@"
117+
Write-Host "End script @$(Get-Date -Format 'yyyy-MM-ddTHH:mm:sszzz')@"

0 commit comments

Comments
 (0)