powershell as admin code example

Example 1: powershell admin privileges

Start-Process powershell -Verb runAs

Example 2: powershell t admin

powershell "start-process powershell -verb runas"

Example 3: admin passwort powershell script

$User = "Username"
$Password = "Password" | ConvertTo-SecureString -asPlainText -Force
$MyCredential = New-Object System.Management.Automation.PSCredential($User,$Password)
 
Start-Process -WindowStyle Hidden powershell.exe -Credential $MyCredential -ArgumentList '-noprofile -command &{Start c:\program\program.exe -Verb RunAs}'