<

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x

The headache of GPO and bulk Copying Files to Domain Joined Computers

0 Points
52 Views
Last Modified:
Mohammed Hamada
I am a senior IT consultant for Azure, Telecom, Messaging and collaboration and Infra. I have been in the IT sector since 15 years.
While doing projects sometimes you have to work with the GPO to copy certain files, scripts to apply commands on domain joined Computers however, The GPO’s File/Folder copying might take long time to gets created and until replication through all clients is done you’ll have to wait...

While doing projects sometimes you have to work with the GPO to copy certain files, scripts to apply commands on domain joined Computers however, The GPO’s File/Folder copying might take long time to gets created and until replication through all clients is done you’ll have to wait for God knows how long in case of enterprise environments. 


After having to copy certain folder to about 800 machine immediately in order to apply certain folder that runs a script through GPO I had to find away to copy the files in fastest way possible and the only way was 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:\Computer.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

0
Comment
0 Comments

Featured Post

Discover the Answer to Productive IT

Discover app within WatchGuard's Wi-Fi Cloud helps you optimize W-Fi user experience with the most complete set of visibility, troubleshooting, and network health features. Quickly pinpointing network problems will lead to more happy users and most importantly, productive IT.

Join & Write a Comment

Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Did you know PowerShell can save you time with SaaS platforms? Simply leverage RESTfulAPIs to build your own PowerShell modules. These will kill repetitive tickets and tabs, using the command Invoke-RestMethod. Tune into this webinar to learn how…

Keep in touch with Experts Exchange

Tech news and trends delivered to your inbox every month