Robocopy命令将文件复制到超过50个远程计算机

编程入门 行业动态 更新时间:2024-10-26 04:32:10
本文介绍了Robocopy命令将文件复制到超过50个远程计算机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我昨天开始查看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个远程计算机

本文发布于:2023-10-17 02:55:04,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1499564.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:命令   文件   计算机   Robocopy

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!