Detect elevated privileges

Sometimes you get a requirement to start a Powershell script from an elevated prompt. Here is a quick function to check that :


This will return a simple boolean so you can use it this way :


Then, you could also enforce the script to create a new process “as Administrator” using the following lines :

Of course ! An UAC Prompt will appear to accept/decline that elevated shell !



Enjoy !


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

How to whitelist website on AdBlocker?

How to whitelist website on AdBlocker?

  1. 1 Click on the AdBlock Plus icon on the top right corner of your browser
  2. 2 Click on "Enabled on this site" from the AdBlock Plus option
  3. 3 Refresh the page and start browsing the site