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