-1

I'm pulling data out from AD using CSVDE. I have a row named "Managers", which gives distinguished name when pulling data. I somehow replaced that value with employee's ID. I executed and got

CN=Manager1,OU=Container,DC=DomainController

Need to replace whole thing with Manager1's employee ID. I can either do it in PowerShell or VB, if necessary.

Vinith
  • 1,264
  • 14
  • 25

1 Answers1

0

Using Powershell and the ActiveDirectory module:

Import-CSV <csvfile> |
  foreach {
           $_.Manager = (Get-Aduser $_.Manager -Properties EmployeeID).EmployeeID
          } |
              Export-CSV <csvfile> -NoTypeInformation
mjolinor
  • 66,130
  • 7
  • 114
  • 135
  • this is what I'm getting Get-ADUser : Cannot bind parameter 'Identity' to the target. Exception setting "Identity": "Cannot validate argument on parameter: 'Identity'. The argument is null or empty. Supply an argument that is not null or empty and then try the command again." – user3005542 Nov 18 '13 at 17:29
  • Can you post sample data from your .csv? – mjolinor Nov 18 '13 at 18:07
  • I can verify that the issues are happening because a lot of the entries don't have any data in that field. Some people don't have managers. I made a test csv and tried your code and it ran, but the output file was blank – user3005542 Nov 18 '13 at 20:04
  • I got the output to work but it is basically taking each manager once and listing them in a separate CSV file. I need it to replace their DN name in the original CSV file to their employee ID – user3005542 Nov 18 '13 at 20:14