In order to Run PowerShell Script as a run Administrator on your Windows (10/11) or Windows Server, you can follow the below easy steps to elevate to an Admin.
Option 1: Right-Click on PowerShell Script file -> Run As Administrator
This is the quickest way to execute the script as an Administrator is by right-clicking on it and choosing "Run as Administrator".
Option 2: Using Start Menu
- Press Windows Button to open Search.
- Now Type PowerShell.
- On the PowerShell icon, right-click and select "Run as Administrator
- Navigate to your PowerShell script and execute it.
Option 3: Using Command Prompt
- Press Windows Button to open Search.
- Now Type Command Prompt.
- On the Command Prompt icon, right-click and select "Run as Administrator" to elevate to admin to run Powershell Script.
- You can execute the script as below,
powershell -ExecutionPolicy Bypass -File "D:\script.ps1
Option 4: using start-process cmdlet to elevate to Admin
If you have already logged into PowerShell and want to elevate as an Administrator, then you can make use of the start-process cmdlet.
start-process PowerShell verb runas
You can also run your script in admin mode with the below one-liner.
Start-Process powershell -ArgumentList "-ExecutionPolicy Bypass -File D:/scripts/schedular_task.ps1" -Verb RunAs
Facing issues? Have Questions? Post them here! I am happy to answer!
Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.
Follow him on: X
You can also reach out to him via e-mail: rakesh@code2care.org
- How to upgrade PowerShell on Mac
- How to install AWS CLI 2 on Windows 11 using PowerShell
- How to switch to Powershell on Mac Terminal
- How to connect to Microsoft Exchange Online using PowerShell
- How to Check PowerShell Version? [Windows/Mac/Linux]
- How to Comment out Code in PowerShell Script
- How to Identify installed PowerShell version
- How to install PowerShell on macOS
- Open PowerShell Terminal in Visual Studio Code (VSCode)
- PowerShell ps1 script is not digitally signed, you cannot run this script on the current system
- Update Powershell Using Command Line
- PowerShell 1..10 foreach Example
- PowerShell Fix: Get-Help cannot find the Help files for this cmdlet on this computer
- List of PowerShell Cmdlet Commands for Mac
- Help or Man equivalent in PowerShell
- PowerShell SubString with Examples
- PowerShell: How to Get Folder Size
- PowerShell Traditional For Loop Example
- PowerShell Switch Statement with Examples
- PowerShell Concatenate String Examples
- PowerShell For Each Loop Examples
- PowerShell: Grep Command Alternative - Select-String
- How to delete a file using PowerShell [Windows/macOS]
- Fix: nano is not recognized as an internal or external command - Windows PowerShell
- PowerShell on Mac: The term get-service is not recognized as a name of a cmdlet, function, script file, or executable program
- 23: Python Programs to concatenate two Lists - Python-Programs
- Microsoft 365: How to Turn Off Delve in SharePoint Online for All Users - SharePoint
- List of Programming Languages Supported by Notepad++ - NotepadPlusPlus
- PHP Base64 encoding decoding a variable - PHP
- List of Rust Cargo Commands - Rust
- Java Stream flatmap() Examples - Java
- How to zoom-in or zoom-out in Windows Notepad - NotepadPlusPlus
- How to Configure Mac with PPPoE Ethernet if using DSL or Cable Modem - MacOS