0

Using the below code in a PowerShell window:

$User = 'testuser1'
$Password = 'Pa$$w0rd' | ConvertTo-SecureString -AsPlainText -Force
$Credential = New-Object PSCredential -ArgumentList $User, $Password
Start-Process powershell -Credential $Credential

This works fine, but the PowerShell instance is not in elevated administrator mode. I tried:

$Arguments = "Start-Process powershell -Verb -RunAs"
Start-Process powershell -Credential $Credential -ArgumentList $Arguments

This opens a PowerShell instance, but it closes immediately.

How can I stop the new, elevated PowerShell instance closing?

LightningWar
  • 915
  • 1
  • 19
  • 35

1 Answers1

0
$Arguments = "Start-Process powershell -Verb RunAs"
Start-Process powershell -Credential $Credential -ArgumentList $Arguments

RunAs is not a parameter but value :)

If you correct this, you will be able to run Powershell console properly.

Vladimir Bundalo
  • 645
  • 8
  • 18