tags:

views:

107

answers:

2

I need to deploy a set of configuration files to a hundred or more Windows hosts.

I have the IP addresses, the user name and password, and the location on the remote machines into which the files should be copied - and was wondering if there was anything in the .NET framework that would let me utilise all that info to move these files?

+2  A: 

Sounds like a job for powershell (assumes powershell v1.0 on your machine - doesn't have to be on servers):

-- begin info.csv --

ipaddress, username, password, path   (<- header)
1.2.3.4, foo, bar, "c:\temp"
5.6.7.8, dog, cat, "c:\temp\foo" 
...

-- end info.csv --

And here's a script which assumes the existance of the above CSV file in the same path.

import-csv info.csv | foreach-object {

    trap { 
       net use t: /delete
       continue
    }

    $root = "\\{0}\{1}" -f $_.ipaddress, ($_.path -replace ':', '$')
    net use t: $root $_.password /user:$_.username
    copy myconfig.config t:
    net use t: /delete
}

This came out of my head, so you might need to tweak it a little but you get the idea.

-Oisin

x0n
This looks like what I'm after. I've never used Powershell before, and I'm getting the following error from your example;Copy-Item : Cannot find drive. A drive with the name 't' does not exist.Any ideas what might be causing that?Cheers
C.McAtackney
this might sound like a retarded question, but are you using a _valid_ CSV file with real IP addresses and share names? If you test the "net use" command on its own, does it create the drive for you?
x0n
Yeah the CSV was valid. It actually turned out to be an unrelated network issue - the hosts were inaccessible from my dev machine, so the mapping to T: was producing the error above.Got it working now. Thanks for your help.
C.McAtackney
+1  A: 

If they're on your AD network, what we usually do is ask our Networking department to deploy them via Group Policy. Since you can build an installer in Visual Studio to install anything (it doesn't have to be an application), you could use this for configuration files as well.

Note: I have no experience with the network end of things. If this is a possibility you may want to ask the question on Server Fault.

TrueWill