Sybux
asked on
Export LDAP information to CSV with powershell
Hello,
I'm trying to create a little script to export some information of my ldap to a CSV file.
I'm using this little script :
but when I export $mylist to csv, I get only the object type and not the value as you can see :
I running it for a quite long time and I can get out where I'm wrong.
Any help should be very welcome.
I'm trying to create a little script to export some information of my ldap to a CSV file.
I'm using this little script :
$strFilter = "((objectCategory=User))"
$objDomain = New-Object System.DirectoryServices.DirectoryEntry("LDAP://OU=Utilisateurs,DC=myldap")
$objSearcher = New-Object System.DirectoryServices.DirectorySearcher
$objSearcher.SearchRoot = $objDomain
$objSearcher.PageSize = 10
$objSearcher.Filter = $strFilter
$objSearcher.SearchScope = "Subtree"
$colProplist = "name","postofficebox"
foreach ($i in $colPropList){$objSearcher.PropertiesToLoad.Add($i)}
$colResults = $objSearcher.FindAll()
$myList = @()
foreach ($objResult in $colResults) {
$objItem = $objResult.Properties
$myUSer = "" | Select-Object Name, PostOfficeBox
$myUser.Name = $objResult.Properties["name"]
$myUser.PostOfficeBox = $objResult.Properties["postofficebox"]
$myList += $myUser
}
but when I export $mylist to csv, I get only the object type and not the value as you can see :
#TYPE Selected.System.String
"Name","PostOfficeBox"
"System.DirectoryServices.ResultPropertyValueCollection","System.DirectoryServices.ResultPropertyValueCollection"
I running it for a quite long time and I can get out where I'm wrong.
Any help should be very welcome.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.