$user = "MyDomain\MyAccount"
$password = ConvertTo-SecureString –String "password" –AsPlainText -Force
$cred = New-Object –TypeName System.Management.Automation.PSCredential –ArgumentList $user, $password
[System.Net.WebRequest]::DefaultWebProxy.Credentials = $cred
but it becomes a problem is the current user credential is used do download files or if the proxy server blocks certain actions. A fantastic tool to resolve this problem is cntlm, which allows you create a local internet proxy.
The configuration (simplified) is as follows:
1. Download and install the software.
2. Set the username and domain in the .ini file. Remove the password setting
3. Type the Url of internet proxy.pac file in a browser and get proxy urls. Add these urls to the config file and remove the 'sample' entries.
4. Execute 'cntlm -M http://www.google.com' and get the authentication type. Copy the Auth and Password to the configuration file.
5. Remove/uncheck the 'Automatic configuration' settings and update the proxy in the browser to point to localhost 3128 (which is configured as the listen port)
You should be good to go.