Check for administrator privileges with PowerShell

PowerShell is an advanced command console. It is extended with a huge set of ready-to-use cmdlets and comes with the ability to use .NET framework/C# in various scenarios. In this article I’ll will show you a short piece of PowerShell code that will check if a PowerShell script is running with administrator privileges or not.

PowerShell script

Save the script for example as Check_Permissions.ps1 and open a PowerShell console without administrator privileges and run:

Result:

Now open a PowerShell console with administrator privileges and run the script again:

I really like to hear what you have to say about this article:

  • Was this article helpful for you or do you have any questions?
  • Do you have additions, suggestions or any other ideas?
  • Just let me know by leaving a comment below.

Thank you for spending some time at my site and in my blog. I hope you come to visit again soon 😉

About Lex van der Horst 201 Articles
Techwire

Be the first to comment

Leave a Reply