I work on a windows service application which can run scripts on a target machine. One of things I need to do is copy files over from my host machine to the target machine for different users. I have explored several solutions but have not found a good one yet. I am listing all that I have tried. Would appreciate if someone has a different/better solution
- start-bitstransfer: This service runs under system account. So only services under system account can use it.
get-content/set-content: Establish a pssession to the target and use set-content within the session. This approach comsumes lot of memory and takes time. For a 1.02 MB file it took more than 2 minutes.
measure-command{$outp = icm -Session $s -ScriptBlock {get-content C:\Programdata\karan\bigfile.txt}; $outp > bfile.txt}
TotalMinutes : 2.20191604 TotalSeconds : 132.1149624 TotalMilliseconds : 132114.9624
For bigger files, the file has to be loaded in chunks and copied which can take even longer
With powershell 3.0 you could use Copy-Item after mapping a network drive with a different credential. But you cannot use multiple users simultaneously which beats the purpose of automation Issue with mapping network drives using New-PSDrive
- Run a webserver and do a http get/post. This is the fastest and the surest, but we will get into opening ports and firewall issues.