Skip to content

Commit e2266da

Browse files
Merge pull request #60 from ActiveDirectoryManagementFramework/development
1.5.78
2 parents c00959e + 31a2ab5 commit e2266da

File tree

4 files changed

+34
-5
lines changed

4 files changed

+34
-5
lines changed

ForestManagement/ForestManagement.psd1

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
RootModule = 'ForestManagement.psm1'
44

55
# Version number of this module.
6-
ModuleVersion = '1.5.76'
6+
ModuleVersion = '1.5.78'
77

88
# ID used to uniquely identify this module
99
GUID = '7de4379d-17c8-48d3-bd6d-93279aef64bb'
@@ -26,7 +26,7 @@
2626
# Modules that must be imported into the global environment prior to importing
2727
# this module
2828
RequiredModules = @(
29-
@{ ModuleName = 'PSFramework'; ModuleVersion = '1.10.318' }
29+
@{ ModuleName = 'PSFramework'; ModuleVersion = '1.12.346' }
3030

3131
# Additional Dependencies, cannot declare due to bug in dependency handling in PS5.1
3232
# @{ ModuleName = 'ResolveString'; ModuleVersion = '1.0.0' }

ForestManagement/changelog.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## 1.5.78 (2024-12-13)
4+
5+
- Upd: Schema - significant test performance improvements
6+
- Upd: Schema - added option to scan _all_ attributes and report any unconfigured ones as "Unmanaged"
7+
38
## 1.5.76 (2024-03-05)
49

510
- Fix: Exchange Schema - invoke fails on validating sites.

ForestManagement/functions/schema/Test-FMSchema.ps1

+26-3
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,13 @@
7474
# Pick up termination flag from Stop-PSFFunction and interrupt if begin failed to connect
7575
if (Test-PSFFunctionInterrupt) { return }
7676

77+
$allAttributes = Get-ADObject @parameters -LDAPFilter "(attributeID=*)" -SearchBase $rootDSE.schemaNamingContext -ErrorAction Ignore -Properties *
78+
$allClasses = Get-ADObject @parameters -LDAPFilter "(objectClass=classSchema)" -SearchBase $rootDSE.schemaNamingContext -ErrorAction Ignore -Properties *
79+
80+
#region Process Configuration
7781
foreach ($schemaSetting in (Get-FMSchema)) {
7882
$schemaObject = $null
79-
$schemaObject = Get-ADObject @parameters -LDAPFilter "(attributeID=$($schemaSetting.OID))" -SearchBase $rootDSE.schemaNamingContext -ErrorAction Ignore -Properties *
83+
$schemaObject = $allAttributes.Where{ $_.attributeID -eq $schemaSetting.OID }[0]
8084

8185
if (-not $schemaObject) {
8286
# If we already want to disable the attribute, no need to create it
@@ -147,7 +151,7 @@
147151
}
148152

149153
if (-not $schemaSetting.IsDefunct -and $schemaSetting.PSObject.Properties.Name -contains 'MayBeContainedIn') {
150-
$mayContain = Get-ADObject @parameters -LDAPFilter "(mayContain=$($schemaSetting.LdapDisplayName))" -SearchBase $rootDSE.schemaNamingContext
154+
$mayContain = $allClasses.Where{ $_.MayContain -contains $schemaSetting.LdapDisplayName }
151155
if (-not $mayContain -and $schemaSetting.MayBeContainedIn) {
152156
$null = $changes.Add((New-AdcChange -Property MayContain -NewValue $schemaSetting.MayBeContainedIn -Identity $schemaObject.DistinguishedName -Type Schema -ToString $mayContainToString))
153157
}
@@ -163,7 +167,7 @@
163167
}
164168

165169
if (-not $schemaSetting.IsDefunct -and $schemaSetting.PSObject.Properties.Name -contains 'MustBeContainedIn') {
166-
$mustContain = Get-ADObject @parameters -LDAPFilter "(mustContain=$($schemaSetting.LdapDisplayName))" -SearchBase $rootDSE.schemaNamingContext
170+
$mustContain = $allClasses.Where{ $_.mustContain -contains $schemaSetting.LdapDisplayName }
167171
if (-not $mustContain -and $schemaSetting.MustBeContainedIn) {
168172
$null = $changes.Add((New-AdcChange -Property MustContain -NewValue $schemaSetting.MustBeContainedIn -Identity $schemaObject.DistinguishedName -Type Schema -ToString $mustContainToString))
169173
}
@@ -191,5 +195,24 @@
191195
}
192196
}
193197
}
198+
#endregion Process Configuration
199+
200+
#region Process AD Only
201+
if (-not (Get-PSFConfigValue -FullName 'ForestManagement.Schema.Attributes.ReportUnconfigured')) { return }
202+
$unconfigured = $allAttributes | Where-Object attributeID -NotIn (Get-FMSchema).OID
203+
foreach ($unexpectedAttribute in $unconfigured) {
204+
if ($unexpectedAttribute.IsDefunct) { continue }
205+
[PSCustomObject]@{
206+
PSTypeName = 'ForestManagement.Schema.TestResult'
207+
Type = 'Unmanaged'
208+
ObjectType = 'Schema'
209+
Identity = $unexpectedAttribute.AdminDisplayName
210+
Changed = $null
211+
Server = $forest.SchemaMaster
212+
ADObject = $unexpectedAttribute
213+
Configuration = $null
214+
}
215+
}
216+
#endregion Process AD Only
194217
}
195218
}

ForestManagement/internal/configurations/configuration.ps1

+1
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,4 @@ Set-PSFConfig -Module 'ForestManagement' -Name 'Schema.Account.AutoDisable' -Val
2929
Set-PSFConfig -Module 'ForestManagement' -Name 'Schema.Account.AutoGrant' -Value $false -Initialize -Validation bool -Description 'Whether the account to use for performing the schema update should be added to the schema admins group before use.'
3030
Set-PSFConfig -Module 'ForestManagement' -Name 'Schema.Account.AutoRevoke' -Value $false -Initialize -Validation bool -Description 'Whether the account to use for performing the schema update should be removed from the schema admins group after use.'
3131
Set-PSFConfig -Module 'ForestManagement' -Name 'Schema.Password.AutoReset' -Value $false -Initialize -Validation bool -Description 'Whether the password of the used account should be reset before & after use.'
32+
Set-PSFConfig -Module 'ForestManagement' -Name 'Schema.Attributes.ReportUnconfigured' -Value $false -Initialize -Validation bool -Description 'Whether Schema attributes that were not configured should be reported as a test finding.'

0 commit comments

Comments
 (0)