Bulk Copy Files to Domain Joined Computers

Facebooktwittergoogle_plusredditpinterestlinkedintumblrmail

While doing projects sometimes you have to work with the GPO to copy certain files, scripts to apply certain commands on clients Computers however, The GPO’s File/Folder creation method takes long time to gets created and until replication through all clients is done you’ll have to wait for “God knows how long” till the shows you placed gets copied to the destination computers.

After having to copy certain folder to about 800 machine immediately in order to apply certain script I had to create a script to copy this folder to all the machines straight ahead.

The script below will read computer hostnames,FQDN from a file that I exported from certain Organizational Unit and check if the Computer is online then copy folder to it if not it’ll report that it’s not online with Red font color and yellow background using Robocopy.

Hope this scripts will help someone out there.

#This Script will copy files to destination computers which you will define in a stored file.
#The Format of the CSV fille will contain only two columns (Name,DNSHostname) you can use the below script to export computer objects from certain OU.
#Get-ADComputer -Filter * -SearchBase “OU=Computers,DC=Domain,DC=com” | select name,dnshostname | Export-Csv C:\Computers.csv -NoTypeInformation
$computers = Import-Csv “C:\computer1.csv”
Start-Transcript
Foreach ($computer in $Computers){
$fullcomp = $computer.dnshostname
If (Test-Connection -ComputerName $computer.name -Quiet) {
.\Robocopy.exe \\SourceServer\c$\nk2edit \\$fullcomp\C$\nk2edit
Write-Host Files has been copied to $fullcomp -ForegroundColor Green -BackgroundColor black}else{
Write-host $computer.name is not online -ForegroundColor Red -BackgroundColor Yellow
}
}

clip_image001

Facebooktwittergoogle_plusredditpinterestlinkedintumblrmail

Leave a Reply

Your email address will not be published. Required fields are marked *

*