1

tI am trying to run a powershell script from another powershell script using alternate credentials.

If I run:

$cred = get-credentials $localArgs = "/c Powershell c:\myscript.ps1" Start-Process cmd.exe -ArgumentList $localArgs -Credential $cred -WindowStyle="Hidden" 

the script errors with:

Start-Process : Parameter set cannot be resolved using the specified named parameters. 

If I remove:

-Credential $cred 

The script runs fine (but with the wrong credentials.)

Am I missing something in terms of how to use the -Credential agument?

Thanks,

Ben

1 Answer 1

1

If you are using the -Credential argument, you may need to also specify the -FilePath argument:

$cred = Get-Credential start-process -FilePath C:\WINDOWS\system32\cmd.exe -Credential $cred 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.