Automated Authentication

Share |

Join PowerShell.com!
Subscribe to Feed

PowerShell eBook
Sign up for
Your PowerTip of the Day:

Award-winning PowerShellPlus


Admin Guide to PowerShell Remoting


Mastering PowerShell eBook

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

Twitter This Tip! ReTweet this Tip!


Posted Jan 12 2011, 08:00 AM by ps1
Copyright 2012 PowerShell.com. All rights reserved.