5

Powershell script search AD non-indexed field

 2 years ago
source link: https://www.codesd.com/item/powershell-script-search-ad-non-indexed-field.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Powershell script search AD non-indexed field

advertisements

I have a need to query AD based on a field that is not one of the fields that is not indexed. We have a field called EmployeeID. When I try to filter on that I get a invalid argument. I can query for any indexed field but I just don't have those.

Import-Module ActiveDirectory
$users = ForEach ($user in $(Get-Content "C:\Users\leaker.AUTH\Documents\MADO - General\Tools\ED Dump tool\ED Dump tool\badgem.txt"))
{

    Get-AdUser $user -filter "EmployeeID -eq '$_.employeeID)'" -Properties SamAccountNAme,displayName,employeeID,mail

}

 $users |
 Select-Object SamAccountNAme,displayName,employeeID,mail |
 Export-CSV -Path "C:\Users\leaker.AUTH\Documents\MADO - General\Tools\ED Dump tool\ED Dump tool\output.csv" -NoTypeInformation

Any Help would be appreciated.


$user will be bound to the Identity parameter - Filter and Identity does not exist in the same parameter set.

Remove -filter "EmployeeID -eq '$_.employeeID)'"

Tags powershell

Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK