-
Notifications
You must be signed in to change notification settings - Fork 392
Jul26SU Release #2566
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Jul26SU Release #2566
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
...HealthChecker/DataCollection/OrganizationInformation/Get-ExchangeLegacySecurityGroups.ps1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| # Copyright (c) Microsoft Corporation. | ||
| # Licensed under the MIT License. | ||
|
|
||
| . $PSScriptRoot\..\..\..\..\Shared\ErrorMonitorFunctions.ps1 | ||
| . $PSScriptRoot\..\..\..\..\Shared\ActiveDirectoryFunctions\Search-AllActiveDirectoryDomains.ps1 | ||
|
|
||
| <# | ||
| .DESCRIPTION | ||
| Searches the forest for legacy Exchange security groups that were created by Exchange 2000/2003 | ||
| and are no longer used by modern Exchange. These groups still carry elevated Active Directory | ||
| permissions, so as a security best practice they should be reviewed and removed if unused. | ||
|
|
||
| Search-AllActiveDirectoryDomains binds to a Global Catalog, so a single forest-wide query covers | ||
| every domain in one round-trip - group objects of all scopes (Global / Domain Local / Universal) | ||
| are published to the GC, and there is no need to iterate each domain individually. | ||
|
|
||
| NOTE: The GC replicates the full membership only for Universal groups. For Global and Domain | ||
| Local groups the 'member' attribute is not available from the GC, so MemberCount is best-effort | ||
| for those scopes and is informational only. | ||
|
|
||
| Reference: https://learn.microsoft.com/en-us/previous-versions/office/exchange-server-2010/gg576862(v=exchg.141) | ||
| #> | ||
| function Get-ExchangeLegacySecurityGroups { | ||
| [CmdletBinding()] | ||
| param() | ||
| begin { | ||
| Write-Verbose "Calling: $($MyInvocation.MyCommand)" | ||
| $legacyGroups = New-Object 'System.Collections.Generic.List[object]' | ||
|
|
||
| # Default sAMAccountName values of the legacy Exchange groups. | ||
| # NOTE: Renamed groups cannot be reliably detected by name. | ||
| $legacyGroupNames = @( | ||
| "Exchange Domain Servers", # Global (one per domain) | ||
| "Exchange Enterprise Servers", # Domain local (forest root) | ||
| "Exchange Recipient Administrators" # Universal (legacy Exchange 2007 role group) | ||
| ) | ||
| } process { | ||
| try { | ||
| $filter = "(&(objectClass=group)(|" + | ||
| (($legacyGroupNames | ForEach-Object { "(sAMAccountName=$_)" }) -join "") + "))" | ||
| $propertiesToLoad = @("distinguishedName", "sAMAccountName", "groupType", "member") | ||
|
|
||
| $searchResults = Search-AllActiveDirectoryDomains -Filter $filter -PropertiesToLoad $propertiesToLoad | ||
|
|
||
| foreach ($result in $searchResults) { | ||
| $distinguishedName = [string]($result.Properties["distinguishedName"][0]) | ||
| Write-Verbose "Found legacy group: $distinguishedName" | ||
|
|
||
| # Decode the group scope from the low bits of the groupType attribute. | ||
| $groupTypeValue = [int]($result.Properties["groupType"][0]) | ||
| $scope = switch ($groupTypeValue -band 0x0000000E) { | ||
| 2 { "Global" } | ||
| 4 { "DomainLocal" } | ||
| 8 { "Universal" } | ||
| default { "Unknown" } | ||
| } | ||
|
|
||
| $legacyGroups.Add([PSCustomObject]@{ | ||
| Name = [string]($result.Properties["sAMAccountName"][0]) | ||
| DistinguishedName = $distinguishedName | ||
| Scope = $scope | ||
| MemberCount = $result.Properties["member"].Count | ||
| }) | ||
| } | ||
| } catch { | ||
| Write-Verbose "Failed to query Active Directory for legacy Exchange security groups. Inner Exception: $_" | ||
| Invoke-CatchActions | ||
| } | ||
| } end { | ||
| return $legacyGroups | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.