Thread: WMI script help
-
August 27th, 2009, 11:45 AM #1
WMI script help
So a seemingly impossible task has been handed to me.
we are in the process of migrating domains and i need to make sure the CIO who did/does a lot of development work doesn't have his old domain account tied to anything important like services.
that said. I was thinking i could write a WMI script to poll the servers for any specific accounts in the local admin groups on the servers.
So i've been using scriptomatic to try this out and i can almost get what i want. But i cannot get it to specify the group in the code.
i'm trying to figure out if it would be worth it to do this in visual studio instead just so i can see any code errors.
anyone ever done anything like this? soon as i add WHERE to the SELECT it breaks.
This is the basic Group users code scriptomatic generates. it works but it essentially pulls every domain account when it hits the Domain Users group.
Code:On Error Resume Next Const wbemFlagReturnImmediately = &h10 Const wbemFlagForwardOnly = &h20 arrComputers = Array("PC") For Each strComputer In arrComputers WScript.Echo WScript.Echo "==========================================" WScript.Echo "Computer: " & strComputer WScript.Echo "==========================================" Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_GroupUser", "WQL", _ wbemFlagReturnImmediately + wbemFlagForwardOnly) For Each objItem In colItems WScript.Echo "GroupComponent: " & objItem.GroupComponent WScript.Echo "PartComponent: " & objItem.PartComponent WScript.Echo Next Next
If i add a WHERE to that such as this it will no longer run. i've also tried sticking the strComputer string in for the "PC" because it will be run with several targets eventually.
Code:On Error Resume Next Const wbemFlagReturnImmediately = &h10 Const wbemFlagForwardOnly = &h20 arrComputers = Array("PC") For Each strComputer In arrComputers WScript.Echo WScript.Echo "==========================================" WScript.Echo "Computer: " & strComputer WScript.Echo "==========================================" Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_GroupUser WHERE GroupComponent = ""Win32_Group.Domain='PC',Name='Administrators'""", "WQL", _ wbemFlagReturnImmediately + wbemFlagForwardOnly) For Each objItem In colItems WScript.Echo "GroupComponent: " & objItem.GroupComponent WScript.Echo "PartComponent: " & objItem.PartComponent WScript.Echo Next NextLast edited by BobOmega; August 27th, 2009 at 11:52 AM.
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
VB/WMI help : copy files between 2 PCs
By bwcc in forum Webmastering and ProgrammingReplies: 0Last Post: October 13th, 2008, 02:03 PM -
WMI problem
By kermani34 in forum Applications and Operating SystemsReplies: 2Last Post: July 19th, 2004, 11:32 AM -
WMI error...Help
By Army2001 in forum Technical SupportReplies: 4Last Post: November 9th, 2003, 09:14 PM -
WMI for Win95
By blubomber in forum Applications and Operating SystemsReplies: 4Last Post: August 16th, 2002, 04:47 PM -
Anyone do any WMI scripting?
By newbie~wan in forum Applications and Operating SystemsReplies: 5Last Post: June 28th, 2002, 09:31 AM



LinkBack URL
About LinkBacks




Reply With Quote

Thank you for the swift reply. As far as I can tell there is no NVidia graphics card pre-installed. The system is an every-day-machine intended for Photoshop related work as well as light 3d...
Does any graphics card work on any...