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

 

if ($host.UI.RawUI.WindowTitle -inotmatch "Administrator") {

Write-Host "Please run this as administrator"
Read-Host “Close this window”

}

Categories:

Comments are closed