Fill in / write / put a string in an empty column in csv file.


hi everybody,

i have large csv file (input.csv) contain many columns / headers “name,surname,firstname,mobilephone,department,ou,samaccountname,address,grade,etc …” column mobilephone empty yet. can mobile phone number active directory no problems. , want put / fill user’s mobile phone number in column mobilephone on same row of user , save csv file. how achieve that? have googled no luck. appreciated! tia.

 

 


win_builder


thanks annawy , clayman2!

after lot of searching, came out next small script works fine:

$inputfile = "c:\temp\inputid.csv"
$csv = import-csv $inputfile -delimiter ";"

foreach($userrow in $csv){
$idtype = $userrow.users_idnr
$usrattribs = get-aduser -ldapfilter "(employeeid=$idtype)" -properties *

#mob# add 2 csv ...
if($usrattribs.mobilephone -ne $null){
        $moblphnnr = $usrattribs.mobilephone
        $xnrattrib = @{""= $moblphnnr;}
        $userrow.mobilephone = $xnrattrib[$userrow.mobilephone];
        $moblphnnr = ""
}
$csv | export-csv "c:\temp\output_inputid.csv" -delimiter "`t" -notypeinformation
}


win_builder



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

Edit Group Policy

Hyper-V VM not reaching OS 'Logon' screen

DNS question...