none
Help is XCOPY to multiple machines RRS feed

  • Question

  • Hey Guys,

    I'm trying to copy an IE11 cab file to all the remote machines.

    xcopy /E /I D:\IE11\cabfiles\IE-Win7.cab \\ISL008687\c$\Windows\Temp\

    The above command works for Single machine, but i have a list of about 200 machines that i will have to copy the file to.

    I'm using the below:

    Psexec @comps.txt cmd /c xcopy /E /I /Y D:\IE11\cabfiles\IE-Win7.cab "c$\Windows\Temp"

    I'm getting a error code 4, obviously the syntax for destination is wrong.

    Can you please guide me here?

    Thanks a lot.



    Regards, Prasad

    Monday, April 27, 2020 3:03 AM

Answers

  • I would just open a Powershell ISE editor as Admin and logged in with domain c$ access credentials and run a script like this:

    # List of computer names
    $computers = Get-Content "C:\Scripts\Computers.txt"
    
    # Source
    $source = "D:\IE11\cabfiles\IE-Win7.cab"
    
    # Destination
    $destination = "c$\Windows\Temp\"
    
    foreach ($computer in $computers) {
        
        if ((Test-Path -Path "\\$computer\$destination")) {
        Copy-Item $source -Destination \\$computer\$destination -Verbose
        Write-Output $computer
        }
        else {Write-Output "\\$computer\$destination is not reachable or does not exist"}
    }

    Computers.txt looks like this:

    ClientPC01
    ClientPC02
    ClientPC03


    Seth

    A user just like you

    • Marked as answer by RealStruggler Monday, April 27, 2020 5:39 AM
    Monday, April 27, 2020 4:29 AM

All replies

  • I would just open a Powershell ISE editor as Admin and logged in with domain c$ access credentials and run a script like this:

    # List of computer names
    $computers = Get-Content "C:\Scripts\Computers.txt"
    
    # Source
    $source = "D:\IE11\cabfiles\IE-Win7.cab"
    
    # Destination
    $destination = "c$\Windows\Temp\"
    
    foreach ($computer in $computers) {
        
        if ((Test-Path -Path "\\$computer\$destination")) {
        Copy-Item $source -Destination \\$computer\$destination -Verbose
        Write-Output $computer
        }
        else {Write-Output "\\$computer\$destination is not reachable or does not exist"}
    }

    Computers.txt looks like this:

    ClientPC01
    ClientPC02
    ClientPC03


    Seth

    A user just like you

    • Marked as answer by RealStruggler Monday, April 27, 2020 5:39 AM
    Monday, April 27, 2020 4:29 AM
  • Thank you Seth.

    I have a similar PS script. I appreciate your help.


    Regards, Prasad

    Monday, April 27, 2020 5:39 AM