1

I am trying to run a command as the Admin user with elevated permissions but PowerShell doesn't support this method.

Start-Process 
-FilePath "powershell" 
-ArgumentList "-Command New-RDSessionDeployment -ConnectionBroker $server -WebAccessServer $server -SessionHost $server" 
-Verb RunAs 
-Credential $creds

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

The combination of Verb and Credential are not supported.

NAME
    Start-Process

SYNTAX
    Start-Process [-FilePath] <string> [[-ArgumentList] <string[]>] [-Credential <pscredential>] [-WorkingDirectory <string>] [-LoadUserProfile] [-NoNewWindow] [-PassThru] [-RedirectStandardError <string>]
    [-RedirectStandardInput <string>] [-RedirectStandardOutput <string>] [-WindowStyle {Normal | Hidden | Minimized | Maximized}] [-Wait] [-UseNewEnvironment]  [<CommonParameters>]

    Start-Process [-FilePath] <string> [[-ArgumentList] <string[]>] [-WorkingDirectory <string>] [-PassThru] [-Verb <string>] [-WindowStyle {Normal | Hidden | Minimized | Maximized}] [-Wait]  [<CommonParameters>]

So how can I run an elevated powershell as another user??

UPDATE: I've come up with this nasty solution but unfortunately it prompts me to approve Elevated permissions which of course is because of UAT.

Start-Process 
-Credential $creds 
-FilePath "powershell" 
-ArgumentList "Start-Process 
    -Verb RunAs 
    -FilePath powershell 
    -ArgumentList '-Command New-RDSessionDeployment -ConnectionBroker $server -WebAccessServer $server -SessionHost $server'"

Is there a way to run that above command as the Domain Admin for automated deployment??

6
  • It is usually considered unwise to have admin credentials (especially domain admin credentials) in a variable like that. Can't you just log in with the right credentials to begin with? Dec 4, 2018 at 9:07
  • Harry Johnston - I understand that but it I still need to run the command as that user which I still couldn't do.
    – Christian
    Dec 4, 2018 at 9:13
  • That's by design. A non-privileged user isn't supposed to be able to elevate to a privileged context without user interaction, though of course there are ways around it if you set them up in advance. One option (not necessarily the best or simplest, just the only one I happen to know will work) would be to use srvany or preferably a similar third-party tool like nssm to create a system service ... Dec 4, 2018 at 18:33
  • ... configure it to run in the domain admin account, and change the permissions so that it can be started by unprivileged users, or by your particular user. (The link shows code for changing the permissions, but you can just take the SDDL string and use it with the sc sdset command.) Dec 4, 2018 at 18:34
  • Ok cool, Thanks Harry. Will look in to it. Certainly can't find any other way!
    – Christian
    Dec 5, 2018 at 9:32

1 Answer 1

0

Check this out: Running Powershell without UAC Prompt

Hope this helps.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .