I've been facing this problem and it doeen't seems to have an end, hope you can help me.
I'm making an LDAP query against Active Directory within a Powershell script. Getting right to the point this is my code:
$objDomain = New-Object System.DirectoryServices.DirectoryEntry("LDAP://OU=ivegotusers,DC=global,DC=foo,DC=com")
$objSearcher = New-Object System.DirectoryServices.DirectorySearcher
$objSearcher.SearchRoot = $objDomain
$objSearcher.PageSize = 1000
$objSearcher.Filter = $strFilter
$objSearcher.SearchScope = "Subtree"
#Write-Host $objSearcher
$colProplist = "name", "sn", "whenCreated", "whenChanged", "createTimeStamp", "modifyTimeStamp", "displayName", "mailNickName"
foreach ($i in $colPropList){
$objSearcher.PropertiesToLoad.Add($i)
}
$colResults = $objSearcher.FindAll()
foreach ($objResult in $colResults){
$objItem = $objResult.Properties;
Write-Host -NoNewLine $objItem.name
Write-Host -NoNewLine "|";
Write-Host -NoNewLine $objItem.displayName;
Write-Host -NoNewLine "|";
Write-Host -NoNewLine $objItem.sn;
Write-Host -NoNewLine "|";
Write-Host -NoNewLine $objItem.whenCreated;
Write-Host -NoNewLine "|";
Write-Host -NoNewLine $objItem.createTimeStamp;
Write-Host -NoNewLine "|";
Write-Host -NoNewLine $objItem.whenChanged;
Write-Host -NoNewLine "|";
Write-Host -NoNewLine $objItem.modifyTimeStamp;
Write-Host "|";
}
So we should get as output a line for each query match, being the line format as follows: name|displayName|sn|whenCreated|createTimeStamp|whenChanged|modifyTimeStamp right?
I've checked the data in the ADSI Edit and a lot of users had that data; nevertheless, the output was
name1||sn1||||
name2||sn2||||
name3||sn3||||
name4||sn4||||
name5||sn5||||
for those same users, and there's not a single line that has more than these two fields seted.
Can anyone help me figuring out what's happening in here?
Note: Due to server set-ups, I'm not able to use the ActiveDirectory import on Powershell.
Regards and thanks for your time! Vlad