proxb / PoshPAIG

PowerShell UI used for auditing and installing updates from WSUS to local and remote systems
MIT License
207 stars 61 forks source link

hide Failover cluster virtual network name accounts #24

Open JohnCroix opened 6 years ago

JohnCroix commented 6 years ago

I have many failover cluster instances that should not be displayed during the LDAP search because they are not real servers and I only want to update real servers. ;) In AD, these objects are created with the description "Failover cluster virtual network name account".

I have changed "$uiHash.LoadADButton.Add_Click" to hide these objects.

LoadADButton Events

$uiHash.LoadADButton.Add_Click({ $domain = Open-DomainDialog $uiHash.StatusTextBox.Foreground = "Black" $uiHash.StatusTextBox.Text = "Querying Active Directory for Computers..." $Searcher = [adsisearcher]""
$Searcher.SearchRoot= [adsi]"LDAP://$domain" $Searcher.Filter = ("(&(objectCategory=computer)(OperatingSystem=server))") $Searcher.PropertiesToLoad.Add('name') | Out-Null $Searcher.PropertiesToLoad.Add('description') | Out-Null Write-Verbose "Checking for exempt list" If (Test-Path Exempt.txt) { Write-Verbose "Collecting systems from exempt list" [string[]]$exempt = Get-Content Exempt.txt } $Results = $Searcher.FindAll() foreach ($result in $Results) { IF ($result.Properties.Item('description') -eq 'Failover cluster virtual network name account'){ continue } [string]$computer = $result.Properties.name If ($Exempt -notcontains $computer -AND -NOT $ComputerCache.contains($Computer)) { [void]$ComputerCache.Add($Computer) $clientObservable.Add(( New-Object PSObject -Property @{ Computer = $computer Audited = 0 -as [int] Installed = 0 -as [int] InstallErrors = 0 -as [int] Services = 0 -as [int] Notes = $Null } ))
} Else { Write-Verbose "Excluding $computer" } } $uiHash.ProgressBar.Maximum = $uiHash.Listview.ItemsSource.count
$Global:clients = $clientObservable | Select -Expand Computer Show-DebugState
})