Wednesday, 25 October 2017

windows - Start-BitsTransfer - "Cannot find path ... because it does not exist" with different credentials to local host


I am typing the following command in a PowerShell prompt:


Start-BitsTransfer -Source "\\serverA\c$\test.txt" -Destination . -TransferType Download -cred (get-credential)

After typing the credentials correctly, I get:



Cannot find path "\\serverA\c$\test.txt" because it does not exist



I can map \\serverA\c$ to a network drive (e.g. Y:\) and then the following works:


Start-BitsTransfer -Source "Y:\\test.txt" -Destination . -TransferType Download

But this is not desirable because I need the capability to be able to download files from more than 26 servers at a time, which means I'll run out of drive letters.



Answer



The New-PSDrive command can create temporary drive mappings within the shell which can be named as any string. Since I do not need these drives to persist, this is a good solution for me, and the -Credential parameter is not bugged (like it is with start-bitstransfer).


New-PSDrive -name "drive1" -PSProvider "FileSystem" -Root "\\serverA\c$" -cred $cred
Start-BitsTransfer -Source "drive1:\\test.txt" -Destination .

This works fine and there's no (unreasonable) limit to the number of temporary drive mappings you can create. For more info about New-PSDrive, see https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/new-psdrive?view=powershell-6


No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...