You know how if you're the administrative user of a system and you can just right click say, a batch script and run it as Administrator without entering the administrator password?
I'm wondering how to do this with a PowerShell script. I do not want to have to enter my password; I just want to mimic the right-click Run As Administrator method.
Everything I read so far requires you to supply the administrator password.
Step 1: Open the Command Prompt, and type the PowerShell as a command, then press Enter key. Step 2: Now, the command prompt will turn to Windows PowerShell. Step 3: Type the command start-process PowerShell -verb runas and press "enter" key. Step 4: It will bring up an elevated Windows PowerShell as an administrator.
Using the run command You can also open a command prompt using a run-box (Windows + R). To do so, open a run-box, write cmd , and press Control + Shift + Enter to open the command prompt as an administrator.
Select “Run as administrator“. If you're running Windows 7, Vista or XP, in order to start Windows PowerShell with administrator privileges, you need to click Start -> All Programs -> Accessories, point to Windows PowerShell, right-click Windows PowerShell, and select Run As Administrator.
If the current console is not elevated and the operation you're trying to do requires elevated privileges then you can start powershell
with the Run as Administrator option :
PS> Start-Process powershell -Verb runAs
Microsoft Docs: Start-Process
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With