Hello
I try to build a report for all relevant properties of a domain like
Schema Version: Get-ADObject (Get-ADRootDSE).schemaNamingContext -Property objectVersion
Exchange Schema Version: Get-ADObject -filter * -SearchBase ((Get-ADRootDSE).schemaNamingContext) -Properties * | Where-Object {$_.Name -eq "ms-Exch-Schema-Version-Pt"}
https://eightwone.com/references/schema-versions/
I have also problems to build the statistic part from the report.
regards
Helmut
# Iterate through the managed domains
$managedDomainsPath = $Context.GetWellKnownContainerPath("ManagedDomains")
$managedDomainsContainer = $Context.BindToObject($managedDomainsPath)
$managedDomainsContainer.Filter = @("adm-ManagedDomain")
foreach ($managedDomain in $managedDomainsContainer)
{
$domain = $managedDomain.Get("DC")
$dn = $managedDomain.Get("distinguishedName")
$rootDse = $Context.BindToObject("Adaxes://$domain/RootDSE")
$nc = $Context.BindToObject("Adaxes://$domain")
$columnValues = @{ }
# description
$descriptionID = "{a175415a-080d-4566-a412-95119b2307d5}"
try { $description = $nc.Get("description") }
catch { $description = "" }
$columnValues.Add($descriptionID, $description)
# whenCreated
$whenCreatedID = "{7ef36b15-f7cf-461f-b8eb-a41312f460f3}"
try { $whenCreated = $nc.Get("whenCreated") }
catch { $whenCreated = "" }
$columnValues.Add($whenCreatedID, $whenCreated)
# whenChanged
$whenChangedID = "{5848c842-7123-41c6-a289-c7458ddbe28d}"
try { $whenChanged = $nc.Get("whenChanged") }
catch { $whenChanged = "" }
$columnValues.Add($whenChangedID, $whenChanged)
# msDS-Behavior-Version (Forest Mode)
$msDSBehaviorVersionID = "{4b3f4fd5-f8fd-4588-a2de-a8cf068e2f2a}"
try { $msDSBehaviorVersion = $nc.Get("msDS-Behavior-Version") }
catch { $msDSBehaviorVersion = "" }
Switch ($msDSBehaviorVersion)
{
"0" {$opModeForest = "Windows 2000 gemischt (DCs: NT, 2000, 2003)"}
"1" {$opModeForest = "Windows Server 2003 interim (DCs: NT, 2003)"}
"2" {$opModeForest = "Windows Server 2003 pur (DCs: 2003 oder neuer)"}
"3" {$opModeForest = "Windows Server 2008 (DCs: 2008 oder neuer)"}
"4" {$opModeForest = "Windows Server 2008 R2 (DCs: 2008 R2 oder neuer)"}
"5" {$opModeForest = "Windows Server 2012 (DCs: 2012 oder neuer)"}
"6" {$opModeForest = "Windows Server 2012 R2 (DCs: 2012 R2 oder neuer)"}
"7" {$opModeForest = "Windows Server 2016 (DCs: 2016 oder neuer)"}
}
$columnValues.Add($msDSBehaviorVersionID, "$msDSBehaviorVersion - $opModeForest")
# msDS-Behavior-Version (Domain Mode)
$msDSBehaviorVersionID = "{2b1942c5-aca7-4dc4-b476-3692dc0ff599}"
try { $msDSBehaviorVersion = $nc.Get("msDS-Behavior-Version") }
catch { $msDSBehaviorVersion = "" }
Switch ($msDSBehaviorVersion)
{
"0" {$opModeDomain = "Windows 2000"}
"1" {$opModeDomain = "Windows Server 2003"}
"2" {$opModeDomain = "Windows Server 2003"}
"3" {$opModeDomain = "Windows Server 2008"}
"4" {$opModeDomain = "Windows Server 2008 R2"}
"5" {$opModeDomain = "Windows Server 2012"}
"6" {$opModeDomain = "Windows Server 2012 R2"}
"7" {$opModeDomain = "Windows Server 2016"}
}
$columnValues.Add($msDSBehaviorVersionID, "$msDSBehaviorVersion - $opModeDomain")
# schema version
$schemaID = {c317c2c0-9c9d-43a5-a2d5-9b9414163197}
#$schema = $rootDse.Get("schemaNamingContext")
#$schema = Get-AdmRootDSE -Server $domain
#$schemavalue = $Context.LogMessage($schema.Get("objectVersion"), "Information")
#$columnValues.Add($schemaID, "schemavalue - ")
# ********** Statistik **********
# Create an instance of the DirectorySearcher class
$searcher = New-Object "Softerra.Adaxes.Adsi.Search.DirectorySearcher" $NULL, $False
$computerID = "{5df9fb3a-bb4b-4384-b322-473b0fb93913}"
$Context.DirectorySearcher.AppendFilter("(objectCategory=computer)")
# Search for computers
try
{
$searchIterator = $Context.DirectorySearcher.ExecuteSearch()
$searchResults = $searchIterator.FetchAll().Count
while ($Context.MoveNext($searchIterator))
{
$computerCount++
}
}
finally
{
if ($searchIterator) { $searchIterator.Dispose() }
}
$Context.Items.Add($Context.DirectorySearcher)
# write to report
$Context.Items.Add($managedDomain, $columnValues )
}