excel - Rename multiple computers -


using netdom command i've changed host name on systems.

netdom renamecomputer oldname /newname:newname /userd:domain\domainid /passwordd:* /force

as need change name of hundred of systems. i've added excel/csv file have 2 columns 'oldname' , 'newname' respectively.

i have tried create function calls above mentioned command line arguments(from each row in excel/csv file).

powershell code

function renameandreboot([string]$computer, [string]$newname) {         $comp = gwmi win32_computersystem  -computer $computer         $os   = gwmi win32_operatingsystem -computer $computer          $comp.rename($newname)         $os.reboot()     }  import-csv mylist.csv  foreach ($entry in $list) {     renameandreboot($entry.oldname,$entry.newname)  }    

i need have same functionality in batch script.

basically want know how import excel in batch file , execute each row.

can me out in this.

you can use for loop on lines of csv file , parse them delimited commas.

read help for , try this

for /f "tokens=1,2 delims=," %%a in (mylist.csv) (   echo netdom renamecomputer %%a /newname:%%b /force ) 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -