Windows Power Shell snippt
#Scirpt reference
function Test-Administrator
{
$user = [Security.Principal.WindowsIdentity]::GetCurrent();
(New-Object Security.Principal.WindowsPrincipal $user).IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)
}
function Write-Log {
Param(
$Message,
$Path = "$env:USERPROFILE\log.txt"
)
function TS {Get-Date -Format 'MM/dd/yy HH:mm:ss'}
"$(TS) - $Message"
}
Write-Log "Starting..."
if ( Test-Administrator) {
Write-Log "Running as Administrator"
}else {
Write-Log "Not Running as administrator"
Write-Log "Exiting..."
Return
}
# Run windows command
&net localgroup administrators
cmd /c --% echo %windir%
cmd /c net localgroup administrators
# Print power shell version
Write-Log $PSVersionTable.PSVersion