running .exe as admin with username and password

Hello,

$server = $env:mfdrives

$apps = "\\$server\Apps\"

Start-Process $apps\faxUploadSetup.exe

When I run this, it opens the faxupload.exe software, which is good, but if I try to install it, it will ask for admin credentials. How would I store the admin usename and password in the script so that when a user runs it, it won’t ask them?

Thank you,

Tony

$Username = "administrator"
$Password = "ThisIsThePassword"
$Credentials = New-Object PSCredential($UserName,$(ConvertTo-SecureString -AsPlainText -String $Password -Force))

$server = $env:mfdrives
$apps = "\\$server\Apps\"

Start-Process $apps\faxUploadSetup.exe -Credential $Credentials

You can obfuscate the credentials using base64 encoding or something else. I still haven’t found of a foolproof way of providing admin credentials to scripts like this. They’re always stored somewhere.

I haven’t been able to try it myself yet, but I’d look into the credential manager rather than saving the password as plaintext.

This module might assist you:

https://www.powershellgallery.com/packages/CredentialManager/

Thank you all,
I’ll try that

Now it says

Start-Process : This command cannot be run due to the error: Logon failure: unknown user name or bad password.

I verified that the username and passwords are correct.