Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Copying Files to Remote Computers

$
0
0

am having difficulties with this script. I would like the files to be copied to &\\$Server\c$\Program Files (x86)\test& if found. If it doesn't find this path, then copy the files to &\\$Server\c$\Program Files\test&.

$Servers = Get-Content '\\apctalk\talkshr2\SWITCHY\computers\computers.txt'

$HotfixPath = '\\apctalk\talkshr2\SWITCHY\app2\*.*'

 

foreach ($Server in $Servers){

   if (Test-Path &\\$Server\c$\Program Files (x86)\test&){

       Write-Host &Processing $Server...&

       

       Copy-Item $Hotfixpath -recurse -container &\\$Server\c$\Program Files (x86)\test&

   

else

   if (Test-Path &\\$Server\c$\Program Files\test&){

       Write-Host &Processing $Server...&

       Copy-Item $Hotfixpath -recurse -container &\\$Server\c$\Program Files\test&

   

              

}

}

}

}


Viewing all articles
Browse latest Browse all 6937

Trending Articles