Solved

powershell Use to copy file and replace to multiple servers

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

Suggested Solutions

In this previous article (https://oddytee.wordpress.com/2016/05/05/provision-new-office-365-user-and-mailbox-from-exchange-hybrid-via-powershell/), we made basic license assignments to users in O365. When I say basic, the method is the simplest way …
The following article is intended as a guide to using PowerShell as a more versatile and reliable form of application detection in SCCM.
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 …

810 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