Solved

powershell Use to copy file and replace to multiple servers

Posted on 2012-03-21
1
592 Views
Last Modified: 2012-04-11
Hi,
I'm thinking could be possible with powershell use to copy the file and replace the file which same name in multiple servers. I'm not into really developer guy so I do not know how to construct this powershell command.
anybody volunteer for the help ?

Method: copy the file let says mon.cfg and distribute it to multiple servers where these servers has the same file name exist.
0
Comment
Question by:motioneye
1 Comment
 
LVL 6

Accepted Solution

by:
NikolasG earned 500 total points
ID: 37746986
You could use the following
$source ="c:\test\* "
$targets = @('pc1', 'pc2', 'pc3') #target computer names
$targetfolder ='c$\'  #target path
	foreach ($cpc in $targets)
	{	
	Write-Host $i.FulName
	Write-Host "To \\"$cpc"\"$targetfolder
	$tar="\\"+$cpc+"\"+$targetfolder
	Copy-Item $source $tar
	}

Open in new window


which copies all the contents of the source folder to the target pcs

Hope it helps.
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Utilizing an array to gracefully append to a list of EmailAddresses
The following article is intended as a guide to using PowerShell as a more versatile and reliable form of application detection in SCCM.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

809 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