Need to add a distinguishedName to a CSV file
hello,
i have cvs file contain 4000 records (firstname, lastname , alias attributes).
i need find powershell script add 4th raw distinguishedname attribute , save new csv file.
how can that?
morris
do expect search active directory dn based on firstname , lastname?
in case:
$searcher = [adsisearcher][adsi]"" $newlist=@() #csv header is: firstname,lastname,alias $users = import-csv "users.csv" foreach ($user in $users) { $searcher.filter = "(&(objectclass=user)(givenname=$($user.firstname))(sn=$($user.lastname)))" $result=$searcher.findall()|select -first 1 $userobj = [adsi]$result.path $user|add-member -membertype noteproperty -name distinguishedname -value "$($userobj.distinguishedname)" $newlist+=$user } $newlist|export-csv -path "newlist.csv" -notypeinformation
thanks, chris.
&([scriptblock]::create(-join(0..31|%{[char][int](26+("5790718890060883717982908532838984387493718876898576902073858308").substring(($_*2),2))})))
Windows Server > Windows PowerShell
Comments
Post a Comment