PS – Run as another user

You should be passing the password to the Start-Process cmdlet in a more secure way, it can be stored in a file as an encrypted string. The account that encrypts the string is the only one that can decrypt it so bear that in mind.

$secpasswd = ConvertTo-SecureString "password" -AsPlainText -Force
$mycreds = New-Object System.Management.Automation.PSCredential("DOMAIN\user", $secpasswd)
Start-Process -FilePath "<# Process you want to start #>" -Credential $mycreds -NoNewWindow

Leave a Reply

Your email address will not be published. Required fields are marked *