home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Ask a Tech Support Question (free)!

WMI script help

Reply
Get bargains at  »  Dealighted.com
 
Thread Tools Search this Thread
Currently Active Users: 2163
Discussions: 200,919, Posts: 2,379,040, Members: 246,287
Old August 27th, 2009, 12:45 PM   Digg it!   #1 (permalink)
Ultimate Member
 
BobOmega's Avatar
 
Join Date: May 2002
Location: Youngstown (well nea
Posts: 1,102
Send a message via ICQ to BobOmega
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
Next

Last edited by BobOmega : August 27th, 2009 at 12:52 PM.
BobOmega is offline   Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Similar Threads
Thread Thread Starter Forum Replies Last Post
VB/WMI help : copy files between 2 PCs bwcc Webmastering and Programming 0 October 13th, 2008 03:03 PM
WMI problem kermani34 Applications and Operating Systems 2 July 19th, 2004 12:32 PM
WMI error...Help Army2001 Technical Support 4 November 9th, 2003 09:14 PM
WMI for Win95 blubomber Applications and Operating Systems 4 August 16th, 2002 05:47 PM
Anyone do any WMI scripting? newbie~wan Applications and Operating Systems 5 June 28th, 2002 10:31 AM


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Most Active Discussions
Is It Just Me? (2844)
Why is Khalid Sheikh Mohammed even .. (9)
Obama the Muslim (9)
Is the PSU I received dead? (10)
windows vista security holes (7)
HIS HD5770 graphic card question (15)
Install XP pro and a Vista laptop ?.. (9)
Foreign voltage (8)
A good PSU? (10)
Dept. of HS: NSA 'Helped' Develop V.. (15)
Print spooler problem (10)
New Computer wont recognize XP disc (7)
Ideal cheap graph card for PC-Gamin.. (15)
EVGA 9800 gtx help with finding a g.. (8)
Recent Discussions
FiOS modem/router interfering with ne.. (7)
Browsers wont load websites (2)
Virus Doctor Popup? (1)
Help getting around port 80 for camer.. (1)
[F@H SPAM 11/16/09] ! 1/2 months to r.. (31)
Foreign voltage (8)
Dept. of HS: NSA 'Helped' Develop Vis.. (15)
windows vista security holes (7)
Install XP pro and a Vista laptop ?? (9)
EVGA 9800 gtx help with finding a goo.. (8)
Modern Warfare For the PC (32)
Problem with speed step/turbo boost? (1)
monitor will not turn on at all, (0)
Modern Warfare 2: Who Bought It? (61)
World's largest Monopoly Game using G.. (330)
Print spooler problem (10)
SIS 740 and Widescreen (8)
Baffling Problem with my CPU/MoBo's. .. (0)
Display shows 3x5 inch in middle of s.. (0)
HIS HD5770 graphic card question (15)
Best file format to play on Windows H.. (0)
PSP Go bought in Japan (0)
Asus P4G8X Mobo (3)
Need hard disk drivers (4)
windows 7 internet problem (4)


All times are GMT -4. The time now is 06:20 PM.
TechIMO Copyright 2009 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28