Is it possible to use PowerShell BitsTransfer to transfer files from a remote session? For instance, without BitsTransfer using only Copy-Item I can do:
$session = New-PSSession -ComputerName some_server;
Copy-Item -FromSession $session -Path 'C:\RemoteDirectory\file.txt' -Destination 'C:\LocalDirectory\file.txt';
But for BitsTransfer there is no equivalent of FromSession parameter:
# Works for local files
Start-BitsTransfer -Source "C:\RemoteDirectory\file.txt" -Destination 'C:\LocalDirectory\file.txt';
I want to use BitsTransfer because it gives me a nice progress bar for larger files, and that's essentially the only reason I need it. Perhaps there is another way to do it altogether?
Thank you in advance for any help!
You can use UNC
pathing to do this.
Start-BitsTransfer -Source "\\server\C$\RemoteDirectory\file.txt" -Destination "C:\LocalDirectory\"
You can also use alternate credentials by using the -Credential
parameter.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.