This topic contains 3 replies, has 3 voices, and was last updated by
December 5, 2018 at 4:43 pm #128281ParticipantTopics: 6Replies: 3Points: 14Rank: Member
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
December 5, 2018 at 5:13 pm #128287ModeratorTopics: 8Replies: 809Points: 2,385Rank: Community Hero
Does the script admin user has access to testuser user's desktop folder ?
Can you try keeping this MSI in c:\temp folder and try .
December 5, 2018 at 7:07 pm #128299ParticipantTopics: 6Replies: 3Points: 14Rank: Member
Thanks for your response — that user does have access to the testuser desktop. I also tried moving the MSI into C:\temp and the results were the same.
I get the same error running this (no args): Start-Process "C:\Windows\System32\msiexec.exe" -Credential $ScriptAdminCreds
December 6, 2018 at 12:51 am #128328ParticipantTopics: 4Replies: 76Points: 328Rank: Contributor
I ran into this issue myself trying to automate software deployments. A suggestion to your $argument variable, prepend your existing string with the /C switch see below:
$Arguments = "/C /package C:\Users\testuser\Desktop\anyconnect-win-4.5.05030-core-vpn-predeploy-k9.msi /norestart /passive"
You have to specify /C before passing cmd any arguments from Powershell start-process cmdlet. I hope this information is helpful for you.
The topic ‘Start-Process as Admin’ is closed to new replies.