Sign in to follow this  
Followers 0
shenj

window user management problem

3 posts in this topic

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?

Share this post


Link to post
Share on other sites



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

Next

EndIf

return $users

endfun

Share this post


Link to post
Share on other sites

Thanks a lot! It works perfect!!!

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0