Testing for Admin Privileges in PowerShell

Sometimes when running a PowerShell script you may need to test at the beginning whether the process it was called from had Windows admin privileges in order to be able to achieve what it needs to do. Prior to PowerShell v4 I had used something along the lines of the following to test for this condition – not the most obvious piece of code ever to be fair:

Click here to be redirected to the original post of this article on the author’s blog site where you can read the remainder of the article.

Posted in:
About the Author

Jonathan Medd

Powershell MVP, VMware vExpert, Co-host of the Get-Scripting Podcast and Co-author of the PowerCLI Book and PowerShell Deep Dives.