I have encountered this recently, and in the most recent versions of Powershell there is a new BitsTransfer Module, which allows file transfers using BITS, and supports the use of the -Credential parameter.
The following sample shows how to use the BitsTransfer module to copy a file from a network share to a local machine, using a specified PSCredential object.
Import-Module bitstransfer
$cred = Get-Credential
$sourcePath = \serverexamplefile.txt
$destPath = C:LocalDestination
Start-BitsTransfer -Source $sourcePath -Destination $destPath -Credential $cred
Another way to handle this is using the standard "net use" command. This command, however, does not support a "securestring" password, so after obtaining the credential object, you have to get a decrypted version of the password to pass to the "net use" command.
$cred = Get-Credential
$networkCred = $cred.GetNetworkCredential()
net use \serverexample $networkCred.Password /USER:$networkCred.UserName
Copy-Item \serverexamplefile.txt C:LocalDestination
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…