# Start-Process as Admin

**URL:** <https://forums.powershell.org/t/start-process-as-admin/11755>\
**Category:** PowerShell Help\
**Created:** [December 5, 2018, 11:13am UTC](https://forums.powershell.org/t/start-process-as-admin/11755 "2018-12-05T11:13:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jzachmans](https://avatars.discourse-cdn.com/v4/letter/j/90db22/32.png) [@jzachmans](https://forums.powershell.org/u/jzachmans)\
**Post date:** [December 5, 2018, 11:13am UTC](https://forums.powershell.org/t/start-process-as-admin/11755/1 "2018-12-05T11:13:11Z")

</div>

Hello All,

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…

…output truncated…

$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

…END…

This is the error – Start-Process : This command cannot be run due to the error: The directory name is invalid.

&nbsp;

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/](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

&nbsp;

&nbsp;

---

<div class="post-metadata">

**Author:** ![kvprasoon](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/kvprasoon/32/4449_2.png) [@kvprasoon](https://forums.powershell.org/u/kvprasoon)\
**Post date:** [December 5, 2018, 11:43am UTC](https://forums.powershell.org/t/start-process-as-admin/11755/2 "2018-12-05T11:43:35Z")

</div>

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 .

---

<div class="post-metadata">

**Author:** ![jzachmans](https://avatars.discourse-cdn.com/v4/letter/j/90db22/32.png) [@jzachmans](https://forums.powershell.org/u/jzachmans)\
**Post date:** [December 5, 2018, 1:37pm UTC](https://forums.powershell.org/t/start-process-as-admin/11755/3 "2018-12-05T13:37:09Z")

</div>

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**

---

<div class="post-metadata">

**Author:** ![bo1](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/bo1/32/33_2.png) [@bo1](https://forums.powershell.org/u/bo1)\
**Post date:** [December 5, 2018, 7:21pm UTC](https://forums.powershell.org/t/start-process-as-admin/11755/4 "2018-12-05T19:21:11Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:33pm UTC](https://forums.powershell.org/t/start-process-as-admin/11755/5 "2024-05-16T20:33:38Z")

</div>


