3

I am currently writing a script that requires copying a file from another machine using a different credential

I followed the step here

Using PowerShell credentials without being prompted for a password

It didn't work for me, when I run Start-BitsTransfer the command prompt still complains that the file I need to copy does not exist

I noticed that if I try and browse the directory I want to copy from and enter the credential when prompted, I was able to copy the file from then on because the credential is somehow cached

I also noticed that the prompt I mentioned above look a bit different from the prompt I would have gotten using "Get-Credential" command

Not sure if that means anything. Anyway, why didn't the solution I found work for me? Any Ideas?

P.S.

Start-BitsTransfer -Source \\RemoteFS\RemoteFile -Destination . -Credential $fsCred Start-BitsTransfer : Cannot find path '\\RemoteFS\RemoteFile' because it does not exist. At line:1 char:1 + Start-BitsTransfer -Source \\RemoteFS\RemoteFile -Destinatio ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (\\RemoteFS\RemoteFile:String) [Start-BitsTransfer], ParentContainsErrorRecordException + FullyQualifiedErrorId : PathNotFound,Microsoft.BackgroundIntelligentTransfer.Management.NewBitsTransferCommand 

Note that, again, after I try and access \RemoteFS\RemoteFile in file explorer and got prompted for credential I was able to run the command just fine because the credential is cached I think

8
  • Would you mind showing the command and error message? Commented Apr 29, 2014 at 1:30
  • UNC path should start with two backslashes \\RemoteFS\RemoteFile Commented Apr 29, 2014 at 19:48
  • A UNC path is a network path. If your remote session is executing on the same machine as the folder, it should use a local path, not a network path. Is the folder on the same machine as the remote session? If the folder is not on the same machine, could accessing the network folder require different credentials than the remote session has? @Cole9350 Looks like Markdown ate some slashes; there are double slashes once I put everything in a code block. Commented Apr 29, 2014 at 21:19
  • @jpmc26 in powershell a unc path will work just as well as a local path. I figured it was just a copy mistake but the path doesn't make sense still. You can't share out an individual file on windows without it being in some sort of shared folder, so it would have to be more like \\RemoteServer\RemoteFS\RemoteFile.file Commented Apr 30, 2014 at 14:07
  • @Cole9350 Right, UNC paths work, but if it's a local file, wouldn't that make the command unnecessarily pull the file from the network? That's what I meant about using a local path. If it's not local, though, the point about additional credentials is still valid. Commented Apr 30, 2014 at 17:32

1 Answer 1

2

Why not the most elegant way, I would simply use "Net Use" and "Net Use /Delete". This definitely works, I'm using it to access a computer that is not part of my domain (during sysprep).

Start-BitsTransfer supports custom credentials, however we have run into few different issues while testing it (I don't remember the details, but good old Net Use work working perfectly for our needs).

Martin

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.