I am currently trying to instruct a newly created windows shell to download a powershell script via autounattend.xml file. With that technique, i need a one liner to get the job done.
I used to be able to download them from a public environment using this one-liner :
<Path>powershell -NoLogo -Command "((new-object System.Net.WebClient).DownloadFile('https://some.remote.public.location/myfile.ps1', 'c:\Windows\Temp\myfile.ps1')"</Path>
But now i need to give in proper credentials to download my file from a private location. I tried the following and it doesn't work :
<Path>powershell -NoLogo -Command "((new-object System.Net.WebClient).Credentials = new-object System.Net.NetworkCredential("user123", "password123")).DownloadFile('https://some.remote.private.location/myfile.ps1', 'c:\Windows\Temp\myfile.ps1')"</Path>
(I'm a rookie in powershell :/)
How can i give the proper credentials to the DownloadFile Method in a one liner?
Or is there another command better suited for the job?
Thanks.