我昨天开始查看robocopy,尝试将文件从一个目的地复制并覆盖到许多远程计算机。我尝试 Robocopy将文件复制到远程机器,但它不工作。我得到与链接中的人相同的错误。有没有人有任何建议或引导我在正确的方式?非常感谢你!
I started looking at robocopy yesterday to try to copy and overwrite a file from one destination to many remote computers. I've tried Robocopy to copy files to a remote machine but it doesn't work. I get the same error as the person in the link. Does anybody have any suggestions or lead me in the right way ? thank you so much !
推荐答案你可以使用PowerShell。它有一个低效率的问题,它会一次复制一个,但这不应该是一个问题为50ish机器。这可以帮助您创建PowerShell脚本
You could just use PowerShell for this. It has an inefficiency issue wherein it would copy one at a time but that shouldnt be an issue for 50ish machines. This could help if you made a PowerShell script
$computers = Get-Content "C:\filewithcomputers.txt" $fileToCopy = "C:\filetocopy.txt" ForEach($computer in $Computers){ Copy-Item -Path $fileToCopy -Destination "\\$computer\C`$\Temp" }将复制文件 $ fileToCopy 到文件 C:\filewithcomputers.txt 中的每个服务器,假设文件包含一个计算机列表,自己的线。该文件将被复制到每台机器上的临时文件夹。根据您的方案所需更新路径。我只建议这样做,因为您标记了 powershell-remoting 。如果你不擅长PowerShell也许别人可以给你一个更好的答案更多的你正在寻找。对一个文件使用RoboCopy看起来很繁琐。
The would copy the file $fileToCopy to each server in the file C:\filewithcomputers.txt assuming that the file contained a list of computer with each one on its own line. The file would be copied to the temp folder on each machine. Update the paths as required for your scenario. I only suggest this since you tagged powershell-remoting. If you are not adept with PowerShell maybe someone else can give you a better answer more of what you are looking for. Using RoboCopy for one file seemed tedious.
如果你想检查一个文件夹是否存在并且可以访问,你可以这样做。
If you wanted to check to see if a folder exists and is accessible you could do something like this.
$computers = Get-Content "C:\filewithcomputers.txt" $fileToCopy = "C:\filetocopy.txt" ForEach($computer in $Computers){ $destinationx86 = "\\$computer\C`$\Program Files (x86)" $destination = "\\$computer\C`$\Program Files" If(Test-Path $destinationx86){ # Copy this to Program Files (x86) Copy-Item -Path $fileToCopy -Destination $destinationx86 } Else { # Copy this to Program Files Copy-Item -Path $fileToCopy -Destination $destination } }更多推荐
Robocopy命令将文件复制到超过50个远程计算机
发布评论