I have a CSV extract from our Oracle HR database that updates the information on telephone, office name, mobile, job title etc. for Active Directory users via Powershell. This works great and version 1 is delivering exactly what the the users wanted, the issues is however, the goal posts have now shifted a little.
Now they have decided that they want the users 'Manager' field populating from the Oracle HR database/CSV extract. It's simple in their mind, it's just name however, as we all know the Active Directory is not just a name, it is actually the distinguished name for the users manager (cn=managername,ou=manager
) and obviously the Oracle HR database does not contain this information.
I am using the following to perform the dump of the live AD and create a CSV to be used for the vLookup;
# Powershell Script to Dump ALL domain users and associated attributes to CSV
# Use Quest ActiveRoles Active Directory Powershell CMDLETs
# Quest AD commandlet command
# Dump All Users to CSV
write-Host "Active Directory User Dump Script" -foregroundcolor "yellow"
write-Host "Writing users to 'D:\Oracle\Backup\DumpAD.CSV'" -foregroundcolor "yellow"
write-Host "Please wait...." -foregroundcolor "yellow"
GET-QADUSER -sizelimit 0 | select-object dn,employeeNumber,sn,givenName,title,telephoneNumber,mobile,department,location,postalAddress,postalCode,mail,comment,manager | export-CSV "D:\Oracle\Backup\DumpAD.CSV" -noType
write-Host "Active Directory User Dump Script Finished" -foregroundcolor "yellow"
write-Host "Please review 'D:\Oracle\Backup\DumpAD.CSV' for full information..." -foregroundcolor "yellow"
write-HOst "### END ###" -foregroundcolor "yellow"
#Email notification of run
send-mailMessage -To email@example.com -From firstname.lastname@example.org -subject 'Active Directory User Dump Complete' -body 'Please note the Active Directory user dump has finished successfully . See attached copy of D:\Oracle\Backup\DumpAD.CSV for full information of dumped accounts' -attachments 'D:\Oracle\Backup\DUmpAD.CSV' -smtp smtpserver.dc.dc
#End of Powershell Script
I need a powershell script to perform a vLookup so I can take the DN from the dump created above and add it as a column to the HR Oracle CSV file so I can populate the 'manager' field with the managers DN.
Any and all advice would be most welcome.