Execution Flow
Synopsis
Reads the HpuDomainGroupMap configuration key — an ordered array of {DomainPattern, GroupNamePattern} objects — and matches the current machine's domain against each entry using PowerShell wildcard syntax. The first matching entry's GroupNamePattern is used as the sAMAccountName filter for an ADSI group search. Returns the group's DistinguishedName on success, or $null on any failure.
No dbatools required. Uses pure ADSI (
[adsisearcher]). Domain patterns support wildcards: exact match ('corp.example.com'), subdomain wildcard ('*.example.com'), or universal catch-all ('*'). Pattern evaluation is ordered — the first match wins.Configuration
# Configure domain-group mappings via Set-sqmConfig Set-sqmConfig -HpuDomainGroupMap @( [PSCustomObject]@{ DomainPattern = 'corp.example.com'; GroupNamePattern = 'Fg_DC_AouAllowManageAuditSecLogSrvAll_Mod' }, [PSCustomObject]@{ DomainPattern = '*.example.com'; GroupNamePattern = 'Rg_DC_AouAllowManageAuditSecLogSrvAll_Mod' }, [PSCustomObject]@{ DomainPattern = '*'; GroupNamePattern = 'Rg_DC_AouAllowManageAuditSecLogSrvAll_Mod' } )
Syntax
Get-sqmHpuAllowGroup [-EnableException]
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| -EnableException | Switch | false | Throw terminating exceptions instead of returning $null and writing warnings. |
Return Value
| Type | Description |
|---|---|
| [string] | DistinguishedName of the matched AD group, e.g. CN=Rg_DC_AouAllowManageAuditSecLogSrvAll_Mod,OU=Groups,DC=corp,DC=example,DC=com. |
| $null | Returned when: domain cannot be determined; HpuDomainGroupMap is not configured; no pattern matches the current domain; group not found in AD. |
Examples
# Resolve the HPU allow group for the current machine Get-sqmHpuAllowGroup # Throw on failure instead of returning $null Get-sqmHpuAllowGroup -EnableException # Use result as input to another function $dn = Get-sqmHpuAllowGroup Write-Host "HPU group DN: $dn"