• Status: Solved
  • Priority: High
  • Security: Private
  • Views: 53
  • Last Modified:

Looking for a script

im looking for a script,

I have a folder, which needs to be copied 100+ servers, and in that a folder I have bat file needs to be executed and it will generate CSV file.
and again all the CSV files needs to be copied back to source.

All servers are in workgroup, not in a domain, uses the same password and user id.

environment windows 2008 r2 std and enterprise

Appreciate your help.. Thanks
0
bsarahim
Asked:
bsarahim
  • 8
  • 7
1 Solution
 
Adam LeinssSenior Desktop EngineerCommented:
How about 3 scripts?

One to copy:

FOR /F "delims=" %%i IN (computers.txt) DO (
 mkdir \\%%i\c$\temp
 xcopy *.* "\\%%i\c$\temp"
)

Open in new window


One to run batch file (download psexec for this):

psexec @computers.txt C:\temp\file.bat

Open in new window


One to copy the data back:

FOR /F "delims=" %%i IN (computers.txt) DO (
 xcopy "\\%%i\c$\temp\*.csv" C:\TEMP
)

Open in new window

1
 
bsarahimAuthor Commented:
Thanks

1. How it will logon to all servers?
2. Incase of any failure, will it halt and have error generated and recorded?

3. FOR /F "delims=" %%i IN (computers.txt) DO (
 mkdir \\%%i\c$\temp
 xcopy *.* "\\%%i\c$\temp"
)

will it read line by line of Computer.txt ?
0
 
Adam LeinssSenior Desktop EngineerCommented:
1. You said the login and password is the same on all machines, so it should use NTLM pass-through authentication to connect to each machine.  When you run the script: you will have to be logged in with this same account and password or the connection to remote machines will fail.

2. It will record the errors to the console from which you run the script interactively.  If you want the results to a file you can re-direct it such as
copyfiles.cmd > copyfiles.log

Open in new window


3. Yes

Start with one computer and test the results.
0
Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

 
bsarahimAuthor Commented:
Thanks a lot..
and also, im planning to execute this script for Domain users for few machines which are in domain, but user id and pwd is same.. (I will not be using Group policy, as due to some rights issue)

will the above script will work?
0
 
Adam LeinssSenior Desktop EngineerCommented:
As long as the script is ran under an account that has admin rights to the remote machines it should work.
0
 
bsarahimAuthor Commented:
hi adam, im getting a error. pls have a look and suggest.. Thanks

in computers.txt file i have the hostnames
error1.png
0
 
Adam LeinssSenior Desktop EngineerCommented:
Change

computers.txt

Open in new window

to

C:\testing\computers.txt

Open in new window


and then try it
0
 
bsarahimAuthor Commented:
Thanks.. but still not working..
0
 
bsarahimAuthor Commented:
sorry attached the screenshot of error .. Thanks
error2.png
0
 
Adam LeinssSenior Desktop EngineerCommented:
I bet the filename is computers.txt.txt.  Do a dir in your command line and see if it shows computers.txt.txt.  If so, rename it to computers.txt and then change the script back to just computers.txt.

You might want to turn on "Show file extensions" in your Windows explorer as well.
0
 
bsarahimAuthor Commented:
Thanks a lot for your wonderful support, you are right.. and it worked.. but i have error in the step2

appreciate your help on this..attached the screenshot
0
 
bsarahimAuthor Commented:
error screen
error3.png
0
 
Adam LeinssSenior Desktop EngineerCommented:
Program Files has a space in the path, so you have to put quotes around it:

"C:\program files\hcl\hchlauncher_win\HCLauncher\cscript-1.bat"
0
 
bsarahimAuthor Commented:
Thanks a lot, it works..

but i need to execute the below..

psexec @computers.txt -c -f -s -d "c:\Program Files\HCL\HCLauncher_Win\HCLauncher\cscript INSTALL.Vbs Windows.2008.CSD.pol"

it says path is not found and i tired with out quotes as well

and install.vbs should be under program files folder
erro4.png
0
 
Adam LeinssSenior Desktop EngineerCommented:
Your best bet is to put a command line in a batch file, copy that to the remote computer and then execute that batch file with psexec.

For the above example you could put:

C:\windows\system32\cscript.exe "c:\Program Files\HCL\HCLauncher_Win\HCLauncher\INSTALL.Vbs Windows.2008.CSD.pol"

Open in new window


Ideally, you want to try this command line by hand first on one of these machines.  Once you get a working command line, throw that into a batch file, then copy that batch file to the remote machines and then fire that batch file with psexec.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell┬« is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

  • 8
  • 7
Tackle projects and never again get stuck behind a technical roadblock.
Join Now