I’m trying to write a small script that installs an MSI (not anything spectacular) but I’m running into an error when using the Start-Process cmdlet with the -Credential switch. I was wondering if you all had any insight…
$AESkey = “location of key”
$EncryptedPassword = “long string of garbage”
$Key = Get-Content $AESkey
$SecuredCreds = ConvertTo-SecureString $EncryptedPassword -Key $Key
$ScriptAdminCreds = New-Object System.Management.Automation.PSCredential (“domain\scriptadmin”, $SecuredCreds)
$Arguments = “/package C:\Users\testuser\Desktop\anyconnect-win-4.5.05030-core-vpn-predeploy-k9.msi /norestart /passive”
Start-Process “C:\Windows\System32\msiexec.exe” $Arguments -Credential $ScriptAdminCreds
This is the error – Start-Process : This command cannot be run due to the error: The directory name is invalid.
Everything works great, except the last line. I am able to run the start-process without the -Credential switch and it works great. But this thing is gonna be run @ logon under user creds and MSIexec needs elevated permissions.
I’ve verified that “domain\scriptadmin” does have NTFS access to System32. I’ve also researched this and tried being more specific with the -filepath switch but I get the same result .(https://www.reddit.com/r/PowerShell/comments/5h7jbr/startprocess_error_directory_name_is_invalid_but/)
Thanks for taking the time to read this. I always appreciate any and all feedback.
Have a great day! -Jared