Check if the current PowerShell session is being "Run as Administrator"

Why even worry about this?

Have you ever tried running a PowerShell script that modifies a simple registry entry? Well, just like other system interactions this won’t work, even if you are logged in as a Domain Administrator. Unless of course you have started your PowerShell session as an Administrator.


image

You might know the System.Security.SecurityException warnings off by heart at this stage. This small post is not an attempt to explain them or the security context of PowerShell executions, that is way out of scope here. But I would like to share a really fast and simple way to determine whether