James O'Neill's Blog

July 24, 2017

An extra for my PowerShell profile–Elevate

Filed under: Uncategorized — jamesone111 @ 7:15 pm

More than usual, in the last few days I’ve found myself starting PowerShell or the ISE only to find I wanted a session as administrator : it’s a common enough thing but eventually I said ENOUGH!  I’d seen “-verb runas” to start an executable as administrator , so I added this to my profile.

Function Elevate        {
    Runs an instance of the current program As Administrator

    Start-Process (Get-Process -id $PID).path -verb runas

Create a free website or blog at WordPress.com.