locked
Copy file/Folder from a remote computer over WinRM/Powershell remote RRS feed

  • Question

  • I am trying to write a function to copy a files over network using WinRM/Powershell Remote as SMP is blocked in firewall.

    I cant use Copy-Item because it doesn't copy the files that are in use

    I cant use Robocopy because it uses SMB (At least I think)

    I cant use [System.IO.File]::ReadAllBytes as it doesnt copy the files in use

    Do you guys have any experience on this situation or could you point me to the direction ?


    Kindly mark as answer/Vote as helpful if a reply from anybody helped you in this forum. Delphin

    Thursday, July 27, 2017 8:15 AM

Answers

  • We decided to copy those files locally on a remote machine using robocopy and then copy all the files to a remote machine using Powershell-remote .

    Kindly mark as answer/Vote as helpful if a reply from anybody helped you in this forum. Delphin

    • Marked as answer by Delphin S A Friday, July 28, 2017 9:13 AM
    Friday, July 28, 2017 9:13 AM

All replies

  • Try robocopy 

    Akshay Pate

    Thursday, July 27, 2017 3:52 PM
  • To copy a file that is locked, you'll need to unlock the file - i.e. break the connection. You can use the Sysinternals handle tool to get the process that is locking the file, then break it. Afterwards, it will be available to copy (I still prefer copy-item).

    https://docs.microsoft.com/en-us/sysinternals/downloads/handle

    Thursday, July 27, 2017 4:08 PM
  • How do I make Robocopy to use WinRm instead of SMB. I cant use anything that uses SMB.

    Plus, I know which process is using those files and I really cant close those handles. The files are log files of SCCM Client and I wouldn't want to terminate SCCM client to view the logs.


    Kindly mark as answer/Vote as helpful if a reply from anybody helped you in this forum. Delphin

    Thursday, July 27, 2017 5:45 PM
  • We decided to copy those files locally on a remote machine using robocopy and then copy all the files to a remote machine using Powershell-remote .

    Kindly mark as answer/Vote as helpful if a reply from anybody helped you in this forum. Delphin

    • Marked as answer by Delphin S A Friday, July 28, 2017 9:13 AM
    Friday, July 28, 2017 9:13 AM