Quantcast
Channel: PowerShell.org » All Posts
Viewing all articles
Browse latest Browse all 13067

List view issue

$
0
0

Hi, just having an issue displaying output in listview. Want to get dc server name in column 1 and site in column 2.

Below shows all the data, but all in column one.

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
$server = $DCs | foreach { ($_ -split 'CN=')[1] -replace ','}
$item2.SubItems.Add($server)
$site = $DCs | foreach { ($_ -split 'CN=')[3] -replace ','}
$item2.SubItems.Add($site)
$list2.Items.AddRange(($server,$site))
}

Thanks
David


Viewing all articles
Browse latest Browse all 13067

Trending Articles