The easiest way I have found without changing UAC settings was to create a 
small batch file that I right click on an select "Run as administrator".
This is the contents of my batch file:
@echo off
set ScriptDirectory=%~dp0
PowerShell -ExecutionPolicy Unrestricted -Command "&'%ScriptDirectory%\script 
name.ps1' -Verbose"

Another option would be to add your script as a function in a PowerShell 
profile.
https://technet.microsoft.com/en-us/library/bb613488(v=vs.85).aspx

I would love to know if someone has a better method.

- Stephen

From: [email protected] [mailto:[email protected]] On 
Behalf Of James Rankin
Sent: Wednesday, August 31, 2016 12:45 PM
To: [email protected]
Subject: [NTSysADM] More PowerShell help

How can I get a PowerShell script to run with administrative privileges?

I have a configuration script I want to run on my Windows 10 machines, 
obviously it is going to be run by an admin user, but I want to just 
double-click the script and it runs with admin privileges. At the minute I have 
to launch PowerShell as an admin and then run the script directly - what's the 
best way to be able to do this with a simple double-click action?

Cheers,


James Rankin
EUC Solutions Architect | 07809 668579 | [email protected]<mailto:[email protected]>
One Trinity Green, Eldon Street, South Shields, Tyne & Wear, NE33 1SA
Tel: 0191 481 3446


Reply via email to