You will not want a credential dialog to pop up if you need to run scripts unattended that need to authenticate using credentials. Here is an example of how to hard-code credentials into your scripts. The example launches a process automatically as a different user:
$user = "fbi\User1"
$password = "P@ssw0rd1" | ConvertTo-SecureString -AsPlainText -Force
$cred = New-Object system.Management.Automation.PSCredential($user, $password)
Start-Process notepad.exe -Credential $cred -LoadUserProfile
ReTweet this Tip!
Jan 12 2011, 08:00 AM