Running a Script to open a program as administrator

Hi, I was wondering if it is possible to create a powershell script that uses the start-process command allowing me to open up a program (lets say cmd) as the administrator?
The reason is I want the ‘do you want to make changes to your pc…’ sign to come up, in order for me to try use send keys to type in the password.

I would appreciate some help as I am new to powershell. thanks.

Start-Process accepts a -Credential parameter which you can use to specify alternate credentials. This will help run the executable with credentials that will allow elevation, however you’ll still be prompted to elevate.

If you wish to immediately elevate, use the -Verb parameter with ‘RunAs’ as the value and that will automatically prompt you to run the process with an admin token. Credential and RunAs however are part of different parametersets therefore they cannot be run together.

I’m not 100% clear on what it is exactly you’re trying to do though? Could you elaborate?

try this

$Username = 'Username'
$Password = 'Password'
$SecurePassword = ConvertTo-SecureString $Password -AsPlainText -Force
$Credential = New-Object System.Management.Automation.PSCredential ($Username,$SecurePassword)

Start-Process powershell.exe  -Credential $Credential -NoNewWindow -ArgumentList "(Start-Process -FilePath '\\some\path\app.exe' -ArgumentList  '/q).ExitCode"

,