In some cases, we need to run some script in administrator mode.
Sometimes we face a situation where we want to know whether the script is running on Administrator mode.
Following script says whether PowerShell script is running on Administrator mode or not.
$elevated = [bool](([System.Security.Principal.WindowsIdentity]::GetCurrent()).groups -match "S-1-5-32-544") if($elevated -eq $false) { throw "In order to install services, please run this script elevated." } else { Write-Host "You are in Administrator mode" }🙂