Skip to content

PowerShell - Check if current session is elevated, if not restart process using -RunAs.

License

Notifications You must be signed in to change notification settings

QuietusPlus/Invoke-ElevateScript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Description

Check if current session is elevated, if not restart process using -RunAs.

Instructions

Place the following code at the top of your script, making sure "Invoke-ElevateScript.ps1" is within the same directory:

. $PSScriptRoot\Invoke-ElevateScript.ps1
Invoke-ElevateScript

Notes

Limitations

Invoke-ElevateScript only works on saved scripts.

Alternative Consoles

Running the function will always start a native PowerShell process (if not yet elevated), even if it was launched using an alternative console like cmder.

About

PowerShell - Check if current session is elevated, if not restart process using -RunAs.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published