Learnt today that I can start a new process within PowerShell with elevated access (i.e. you get a UAC prompt that gives you more rights) using the Verb
switch to the Start-Process
cmdlet.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# Start a new PowerShell window with elevated rights. Notice the "runas". PS> Start-Process -Verb runas -FilePath powershell # It looks like you can't combine runas with a different credential though PS> Start-Process -Credential rakhesh -Verb runas -FilePath powershell Start-Process : Parameter set cannot be resolved using the specified named parameters. At line:1 char:1 + Start-Process -Credential rakhesh -Verb runas -FilePath powershell + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Start-Process], ParameterBindingException + FullyQualifiedErrorId : AmbiguousParameterSet,Microsoft.PowerShell.Commands.StartProcessCommand # Removing the runas gets the command working so the problem is the combination PS> Start-Process -Credential rakhesh -FilePath powershell # Workaround is to start a new PowerShell session as the user first and pass this process # a Start-Process cmdlet to create a PowerShell process with UAC. PS> Start-Process -Credential rakhesh -FilePath powershell -ArgumentList "Start-Process powershell -verb RunAs" |