Public/Get-ADComputerList.ps1
Function Get-ADComputerList { <# .SYNOPSIS Accepts an array of Strings from Get-AllArrayData to query ad with using different -LDAPFIlter queries .PARAMETER SearchTerm [array]$SearchData Specifies the Data to use to construct the search filters .PARAMETER Filters $Filters = @("ComputerName", "samaccountname", "distinguishedName", "DNSHostName", "name", "") Specifies the AD Computer properties to search against, keep these filter parameters specific to Computer Objects and make sure they are Unique to each Computer to maintain exact matches .OUTPUTS Returns an array of all Unique Computer objects found from searching .EXAMPLE $Properties = Get-Properties $Array $AllData = Get-AllArrayData -Array $Array -Properties $Properties $Results = Get-ADComputerList $AllData #> [CmdletBinding()] param ( [Parameter()] [array] $SearchData, $Filters = @("ComputerName", "samaccountname", "distinguishedName", "DNSHostName", "name") ) $Results = @() Foreach ($Filter in $Filters) { Write-Verbose "Running Search on $Filter Filter" $SearchFilter = $SearchData -join ")($Filter=" $SearchFilter = "(|($Filter=$SearchFilter))" Write-Debug $SearchFilter $Results += Get-ADComputer -LDAPFilter $SearchFilter } $Results = $Results | Sort-Object -Unique Return $Results } |