60aside Posted December 30, 2009 Share Posted December 30, 2009 Hi, The following script gives a msgbox with the local groups on the computer. It's working fine on XP/Vista/7 but does not display anything on Windows 2000. Has anyone got any ideas why? $objWMIService = Objget("winmgmts:"&"{impersonationLevel=impersonate}!\\" & "." & "\root\cimv2") If Not IsObj($objWMIService) Then msgbox(0,"Error","Unable to connect to " & ".") Exit Endif $colItems = $objWMIService.ExecQuery(("Select * from Win32_Group Where LocalAccount = True")) For $objItem in $colItems $group = StringSplit($objItem.Caption,'\') msgbox(0,"", $group[2]) Next Thanks. Link to comment Share on other sites More sharing options...
Lotheron Posted December 30, 2009 Share Posted December 30, 2009 (edited) Try this: $strComputer = "ComputerName" $objWMIService = Objget("winmgmts:"&"{impersonationLevel=impersonate}!\\" & $strComputer & "\root\cimv2") If Not IsObj($objWMIService) Then msgbox(0,"Error","Unable to connect to " & ".") Exit Endif $colItems = $objWMIService.ExecQuery(("Select * from Win32_Group Where Domain = '" & $strComputer & "')) For $objItem in $colItems $group = StringSplit($objItem.Caption,'\') msgbox(0,"", $group[2]) Next The reason the script won’t run on Windows 2000 is because, prior to Windows XP, the Win32_Group class did not support the property LocalAccount. Change the computer name from . to the local computer name and look for groups where the domain is equal to the local computer. Edited December 30, 2009 by Lotheron Link to comment Share on other sites More sharing options...
60aside Posted December 30, 2009 Author Share Posted December 30, 2009 That works great. Thanks a lot. 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