Public/Get-ADUserList.ps1
Function Get-ADUserList { <# .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 = @("employeeid", "samaccountname", "distinguishedName", "mail", "name") Specifies the AD User properties to search against, keep these filter parameters specific to user Objects and make sure they are Unique to each user to maintain exact matches .OUTPUTS Returns an array of all Unique user objects found from searching .EXAMPLE $Properties = Get-Properties $Array $AllData = Get-AllArrayData -Array $Array -Properties $Properties $Results = Get-ADUserList $AllData #> [CmdletBinding()] param ( [Parameter()] [array] $SearchData, $Filters = @("employeeid", "samaccountname", "distinguishedName", "mail", "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-ADUser -LDAPFilter $SearchFilter } $Results = $Results | Sort-Object -Unique Return $Results } |