Solved

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

Posted on 2009-07-15
5
243 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

896 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now