Start-Process as Admin

Welcome Forums General PowerShell Q&A Start-Process as Admin

This topic contains 3 replies, has 3 voices, and was last updated by

5 months, 2 weeks ago.

  • Author
  • #128281

    Topics: 6
    Replies: 3
    Points: 14
    Rank: Member

    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


    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 .(

    Thanks for taking the time to read this. I always appreciate any and all feedback.

    Have a great day! -Jared



  • #128287

    Topics: 8
    Replies: 809
    Points: 2,385
    Helping Hand
    Rank: 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 .

  • #128299

    Topics: 6
    Replies: 3
    Points: 14
    Rank: 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

  • #128328

    Topics: 4
    Replies: 76
    Points: 328
    Helping Hand
    Rank: 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.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort