Solved

Can you copy a folder to all computers in an OU?

Posted on 2009-07-15
5
245 Views
Last Modified: 2012-05-07
This is a question that has been bugging me for some time. I would like to know if there is a way to run a VBScript that would copy a folder to all computers within an OU? I know this can be done with GP, but I would really like to see if it can be done from my machine or server with a script.
0
Comment
Question by:error131
  • 3
  • 2
5 Comments
 
LVL 33

Accepted Solution

by:
Todd Gerbert earned 500 total points
ID: 24863920
So, for example, on your computer you have a folder called "DistributionSource" on your C: drive, and you want it copied to "C:\DistributionDest" on every computer in a given OU?

I didn't test this, but in theory I think it should work so long as you have admin access to the remote machines.
Option Explicit
 
Dim FileSystem
Dim OU
Dim computer
 
Set FileSystem = CreateObject("Scripting.FileSystemObject")
Set OU = GetObject("LDAP://OU=Computers,DC=yourdomain,DC=com")
OU.Filter = Array("computer")
 
For Each computer in OU
	FileSystem.CopyFolder "C:\DistributionSource", "\\" & computer.Name & "\c$\DistributionDest"
Next

Open in new window

0
 

Author Comment

by:error131
ID: 24864186
That is exactly what I am looking for.
I tried running your script but it says path not found on line 12. I am pretty sure I have it correct, but mabey you know somthing I don't.
0
 

Author Comment

by:error131
ID: 24864346
I see now. It pulls the destination path like this > 
\\CN=DAVID-LAURENT\d$\test

0
 

Author Comment

by:error131
ID: 24869385
Well in the end I had to go a little differnt way. But this seems to work great.
Set objOU = GetObject("LDAP://ou=ittestou,dc=domain,dc=com") 
objOU.Filter = Array("computer") 
Set objFSO = CreateObject("Scripting.FileSystemObject") 
For Each objComputer In objOU 
    strNTName = objComputer.sAMAccountName 
         strNTName = Left(strNTName, Len(strNTName) - 1) 
    If (objFSO.FolderExists("\\" & strNTName & "\d$\iaclient") = False) Then 
 objFSO.CopyFolder "\\testserver\applications\interaction\5.6sp2", "\\" & strNTName & "\d$" 
    End If 
Next 

Open in new window

0
 
LVL 33

Expert Comment

by:Todd Gerbert
ID: 24869940
Sorry...saw your post last night & forgot to respond, but you've got exactly what I would've said anyway!
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
A quick step-by-step overview of installing and configuring Carbonite Server Backup.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question