Solved

powershell Use to copy file and replace to multiple servers

Posted on 2012-03-21
1
587 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This article will help you understand what HashTables are and how to use them in PowerShell.
A procedure for exporting installed hotfix details of remote computers using powershell
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

914 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

23 Experts available now in Live!

Get 1:1 Help Now