Getting DC attributes

Hi,

As far as I can see, even though active directory shows site information for domain controller’s, it doesnt have an attribute?

I have this function and just want to add the site information to the list view. Even if its as simple as if DC1 equals DC1, shows description as Default-First-Site-Name etc.

This works, but dont know where to start to pull the site info. Tried alsorts.

function updatedclist { $DCs = get-qadcomputer -SearchRoot 'domain/domain controllers' $progress2.value = 20 if ($DCs.count){$progress2.step = (80/$DCs.count-1)} else{$progress2.step = 80} foreach($DC in $DCs){ $progress2.value += $progress2.step $item2 = new-object System.Windows.Forms.ListViewItem($DC.name) $item2.Tag = $DC $list2.Items.Add($item2) > $null } #End foreach $progress2.visible = $false $lbldc.visible = $true $form2.Text = "Select Domain Controller" } #End function updatedclist #Save the initial state of the form $InitialFormWindowState2 = $form2.WindowState #Init the OnLoad event to correct the initial state of the form $form2.add_Load($OnLoadForm_StateCorrection2) $form2.add_Load({updatedclist}) #Show the Form $form2.ShowDialog()| Out-Null }

Thanks Dave

That information isn’t directly linked to the computer accounts in the domain parititon. You’d have to search the configuration partition for the corresponding NTDS Settings object (class nTDSDSA), which will be found under a site’s Servers container.

Thanks you

Do you know how I can then add the CN=Default-First-Site-Name as a subitem to the list view?

function updatedclist { $Config = ([adsi]"LDAP://rootdse").ConfigurationNamingContext $dse = [adsi]"LDAP://$config" $searcher = New-Object DirectoryServices.DirectorySearcher ($dse, "ObjectClass=nTDSDSA") $searcher.findall() | ForEach-Object{ $DCs = new-object System.Windows.Forms.ListViewItem([adsi]$_.path).parent $item2 = $DCs | % { ($_ -split ',')[0] -replace 'ListViewItem: {LDAP://CN=' } #$item2.SubItems.Add() $list2.Items.Add($item2) > $null } $progress2.visible = $false $lbldc.visible = $true $form2.Text = "Select Domain Controller" } #End function updatedclist