shenj Posted November 19, 2008 Share Posted November 19, 2008 I want to make sure that the specific user account is joined to the local administrators group.I want to query users in local administrators how can i do it? Link to comment Share on other sites More sharing options...
99ojo Posted November 19, 2008 Share Posted November 19, 2008 I want to make sure that the specific user account is joined to the local administrators group.I want to query users in local administrators how can i do it?if the query is local: net localgroup administrators. This will list the local users belonging to the local group administrators.if you have to query remote this may help you. You have to change code:CODE$wbemFlagReturnImmediately = 0x10$wbemFlagForwardOnly = 0x20$strComputer = "Computername"$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")MsgBox(1,"","Administrators:" & @crlf & groupusers("Administrators"))Func groupusers($group)$users = ""$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_groupuser where GroupComponent = ""Win32_Group.Domain='" & $strComputer & "',name='" & $group & "'""" _ , "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)If IsObj($colItems) then For $objItem In $colItems $dom=StringInStr($objItem.PartComponent,"domain=") $name = StringTrimRight(StringReplace(StringMid($objItem.partcomponent,$dom+8),""",Name=""","/"),1) if stringinstr($users,$name) = 0 Then if $users<>"" Then $users = $users & " " endif $users = $users & $name endif NextEndIfreturn $usersendfun Link to comment Share on other sites More sharing options...
shenj Posted November 20, 2008 Author Share Posted November 20, 2008 Thanks a lot! It works perfect!!! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now