Here is a PowerShell code snippet to find out if a script is run as Administrator: