Archive for January 2014


Again after longtime I am writing here 🙂

Earlier today I was having bunch of Servers on which I was not sure if I have access to all of them. I wanted to know the server list on which my network ID is added to the Local Administrator Group. 🙂

I came up with below powershell script which help us to find out if the network ID has been added to the administrator list or not (Mainly for Remoting into the Server :))

$Servers = Get-Content C:\Servers.txt
Foreach($strComputer in $Servers)
$computer = [ADSI](”WinNT://” + $strComputer + “,computer”)
$Group = $computer.psbase.children.find(”Administrators”)
[string]$members = ($Group.psbase.invoke(”Members”) | %{$_.GetType().InvokeMember(”Adspath”, ‘GetProperty’, $null, $_, $null)}) -replace (‘WinNT://DOMAIN/’ + $server + ‘/’), ” -replace (‘WinNT://DOMAIN/’, ‘DOMAIN\’) -replace (‘WinNT://’, ”)
$m = $members.Replace(” “,”,”)
$k = $m.Replace(“/”,”\”)
[array]$l = $k -split “,”
if(($l | %{$_}) -eq “\User1”)
Write-Host “You have admin rights on $StrComputer”
Write-Host “You don’t have admin rights on $StrComputer”
Write-Host “$Strcomputer has an exception”

The server list will go in C:\Servers.txt\User1 — is the account name which you want to validate.

I hope this helps.


-Prashant Girennavar.