Jump to content

window user management problem


shenj
 Share

Recommended Posts

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

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...