I'm trying to automate the download of some files using "start-bitstransfer" cmdlet, but I should use a proxy.
Wen I use "get-credentials" there is no problem there is no problem to download the file, but I'd like to avoid prompting for the current user session. $mycred=get-credential Start-BitsTransfer -proxyusage override -proxylist @("myproxy.com:8080") -proxycredential $mycred -Proxyauthentication Ntlm http://go.microsoft.com/fwlink/?LinkId=76054 .\wsusscn2.cab
But when I'm trying to use the defaultcredentials to avoid prompting for it $mycred= [System.Net.CredentialCache]::DefaultCredentials
I'm getting and error related with the "username" like this: Start-BitsTransfer : Cannot process argument transformation on parameter 'ProxyCredential'. userName
How can I use the default user session credential ? I've tried with other samples I've seen to pass credentials to proxy, but none was working. Any suggestion?
Regards
It appears that
Start-BitsTransfer
is unable to use default credentials because of the underlying .NET method that handles asynchronous file transfers.If
Start-BitsTransfer
is not a hard requirement, I would recommendWebClient
.A function to create a
$global:webClient
object;Now call the function, then have the .Net object download the file.