# ===================================================================================

#Checks whether the script is running as admin, if not then starts as admin.

# ===================================================================================

If (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] “Administrator”))

{

$arguments = “& ‘” + $myinvocation.mycommand.definition + “‘”

Start-Process powershell -Verb runAs -ArgumentList $arguments

Break

}