어제 robocopy를보고 한 대상에서 많은 원격 컴퓨터로 파일을 복사하고 덮어 쓰려고했습니다. 나는 Robocopy to copy files to a remote machine을 시도했지만 작동하지 않습니다. 나는 링크에있는 사람과 같은 오류가 발생합니다. 아무도 제안을하거나 올바른 방법으로 나를 인도합니까? 정말 고맙습니다 !Robocopy 명령을 사용하여 50 개가 넘는 원격 컴퓨터에 파일 복사
1
A
답변
1
여기에 PowerShell을 사용할 수 있습니다. 그것은 한 번에 하나씩 복사 할 수 있지만 50 미리 기계에서는 문제가되지 않는 비 효율성 문제가 있습니다. 당신이
$computers = Get-Content "C:\filewithcomputers.txt"
$fileToCopy = "C:\filetocopy.txt"
ForEach($computer in $Computers){
Copy-Item -Path $fileToCopy -Destination "\\$computer\C`$\Temp"
}
(가) 파일이 한 줄에 각각 컴퓨터의 목록을 포함한다고 가정 파일 C:\filewithcomputers.txt
의 각 서버에 파일 $fileToCopy
을 복사합니다 PowerShell 스크립트를 만든 경우에 도움이 될 수. 파일은 각 시스템의 임시 폴더에 복사됩니다. 시나리오에 필요한대로 경로를 업데이트하십시오. 나는 당신이 powershell-remoting이라고 태그를 지정했기 때문에 이것을 제안합니다. PowerShell에 익숙하지 않은 경우 다른 사람이 찾고있는 것보다 더 나은 답변을 줄 수 있습니다. 한 파일에 RoboCopy를 사용하는 것은 지루한 것처럼 보였습니다.
폴더가 존재하고 액세스 가능한지 확인하려면 다음과 같이하십시오. 당신이 다른 자격 증명와 연결해야하는 경우
$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
}
}
1
, 당신은 당신이 예에 복사 할 수 있습니다 이제
$credential = Get-Credential
New-PSDrive -Name "Computer01" -PSProvider FileSystem -Root "\\Computer01\Share" -Credential $credential -Scope global
사용할 수 있습니다 Computer01 : \ Folder01 \
0
환경을 PSRemoting을 지원하도록 설정하고 파일 공유에 배치 한 경우 PowerShell Remoting을 사용하여 많은 컴퓨터에서 Invoke-Command와 거의 동시에 파일을 검색하도록 지시 할 수 있습니다. 당신은 소스 파일의 크기가 얼마나 강력한 네트워크/서버에 따라 -ThrottleLimit를 사용하여 동시 작업의 수를 제한 할 수 있습니다
$computers = Get-Content "C:\filewithcomputers.txt"
$originalsource = "\\fileserver\shared\payload.exe"
$originaldestination = "c:\"
$scriptblockcontent = {
param($source,$destination)
Copy-Item -Path $source -Destination $destination
}
Invoke-Command –ComputerName $Computers –ScriptBlock $scriptblockcontent `
–ThrottleLimit 50 -ArgumentList $originalsource,$originaldestination
당신은 단지 하나 개의 파일은 PowerShell을'복사 품목 C를 사용할 수를 복사하는 경우 : \ local \ folder \ file.txt \\ Server \ C $ \ Path' UNC 경로를 지원하므로 – Matt
RemoteNames.txt에있는 여러 원격 컴퓨터에 하나의 파일을 둘 수 있습니까? 매트에게 대답 할 시간을 내 주셔서 감사합니다. – user2297185