topics that matter; ideas worth sharing

share a tip, submit a link, add something new

Windows Tip: Enumerating local admin group membership

October 12, 2007, 11:55 AM —  ITworld.com — 

Send your Windows question to Mitch today! | See other Windows tips



Awhile back I wrote a series of introductory articles about WMI scripting. In one article, I posted the following question: "How can you list any local administrator accounts on a remote machine?" The solution I offered used the Windows Management Instrumentation Command-line (WMIC), a command interpreter that let's you query WMI information directly from the command line instead of doing it from within a WMI script. The command I suggested using was wmic path win32_groupuser where (groupcomponent="win32_group.name=\"administrators\",domain=\"%computername%\"") and this command produces the Administrator account list for the specified computer.



Recently, reader Gene Cox contacted me with this follow-up question: "How can I leverage this for multiple machines?" I asked Gene what the scenario was that he was trying to address, and he replied that he wanted to "Verify all Administrators group on each machine in the domain contain the [minimum] number of authorized users ... Laptop users by nature and by usage need to be local administrators to their corporate machines can add other users to the Admin group. LAN Admins by nature and by usage need to be administrators to all corporate machines in their regions can add other users to the Admin group ... you see where this is going. This is a gauge of abuse or variation from the normal standards. It can easily [be] changed for "other" groups, such as Power Users, etc."



In response to Gene's needs, I suggested taking the above WMIC command and parsing it using a "FOR /F" CMD statement and passing it a parameter to WMIC as follows:


for /f %i in (MyComputerList.txt) do wmic /Node:%i path win32_groupuser where
(groupcomponent="win32_group.name=\"administrators\",domain=\" %i\"")

Gene replied afterward and told me that this solution "works well" and I was gratified to hear this. Being a Microsoft Most Valuable Professional (MVP), I believe that part of my mandate as an IT professional is to spend a good chunk of my free time helping other IT pros whenever I can with their technical problems. So feel free to send me your own Windows-related technical questions and I'll try and see if I can answer them, and if I can't, then at the least I'll try to point you in the direction of some other experts who might be able to help.

 

ITworld.com

I like it!
Post a comment
The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
Resources
White Paper

Symantec Backup Exec 12 and Backup Exec System Recovery 8 deliver industry leading Windows data protection and system recovery. Download this whitepaper to find out the top reasons to upgrade and how to get continuous data protection and complete system recovery.

Webcast

Data and system loss — from a hard drive failure, malicious attack, natural disaster, or simple human error — can happen anytime. Don’t leave your business vulnerable. Make sure you have a secure recovery strategy in place. Symantec's latest backup and system recovery technology can efficiently restore critical applications, individual emails and documents and even restore your entire system in minutes in the event of a loss.

White Paper

Businesses face a growing challenge to ensure that the IT environment is properly protected. Backup Exec 12 integrates with other applications in the Symantec family of products, to complement your current data protection strategy, keep your data securely backed up and make it recoverable when you need it most.

Free stuff
Featured Sponsor

AISO founders envisioned a Web hosting company that was environmentally friendly. While the company employed energy-efficient innovations like solar panels, its infrastructure produced unacceptable power and cooling requirements. Find out how AISO leveraged AMD technology to overcome their challenge in this case study white paper.

In this whitepaper, Scalar explores the opportunity to change the landscape with respect to mission critical databases built around Oracle. Leveraging technologies such as Linux, high-end commodity processing power and Oracle RAC technology to architect, design, build and maintain database infrastructure that delivers maximum availability, reliability and performance at a fraction of traditional cost.

On a typical day, weather.com, the Web site for The Weather Channel in Atlanta, serves up between 15 million and 20 million page views. But in September 2004, when back-to-back hurricanes ransacked Florida, the peak traffic on one day more than tripled: over 70 million page views by more than 7 million unique visitors. Read the full success story now.

More Resources