Welcome to MSDN Blogs Sign in | Join | Help

jaredpar's WebLog

Code, rants and ramblings of a programmer.

Syndication

News

Now Reading

Expert F#

What's a better book to read when learning F#?

Essential WPF

Thus far the best book I've read on WPF. Gets right down to working with WPF and the goals/history.

Purely Functional Data Structures

Reading this book makes me feel like I'm back in college. It will really get your mind going and is best read with a whiteboard handy.

Blog Roll

Eric Lippert
Dustin Campbell
Jon Skeet
Coding Horror
Brian McNamara
Brian Bondy
Hub FS
Full List

Determining if you're an Administrator from Powershell

Here's a handy PowerShell function I used to determine if I'm currently running as an Administrator in PowerShell

# Determine if I am running as an Admin
function AmIAdmin()
{
 $ident = [Security.Principal.WindowsIdentity]::GetCurrent()
 
 foreach ( $groupIdent in $ident.Groups )
 {
  if ( $groupIdent.IsValidTargetType([Security.Principal.SecurityIdentifier]) )
  {
   $groupSid = $groupIdent.Translate([Security.Principal.SecurityIdentifier])
   if ( $groupSid.IsWellKnown("AccountAdministratorSid") -or $groupSid.IsWellKnown("BuiltinAdministratorsSid"))
   {
    return $true;
   }
  }
 }
 
 return $false;
}

Published Friday, January 19, 2007 2:34 PM by Jared Parsons

Filed under: ,

Comments

No Comments

New Comments to this post are disabled
Page view tracker