Tech

Guides
 

Output local group membership on Windows Server

By Rick Vanover, Special to ZDNet Asia
Tuesday, December 01, 2009 11:20 AM
Command line skills for Windows Servers are essential to deliver information without wasting time. Here's how an old tool and a new tool can help.

What do you do when you need to know the list of local administrators on every Windows Server in a hurry? It can be a tricky task if approached in a poor manner.

Generating an output of Active Directory-based group membership is easy with many command-line tools such as CSVDE and LDIFDE. Local accounts, however, are a different beast. Further, determining the membership of a local security group is important, as Group Policy configurations may not be applied as expected for a number of reasons.

To help with this challenge, we'll lean on an old tool: the net command. The net command is sacred stuff to me, and I have trouble parting with the quick one-liners that have made me look good over the years.

For the example to enumerate what usernames are a local administrator on a Windows Server, run the following command:

Net localgroup "Administrators"

The output will enumerate each username or group that composes the local administrators group; this will include members that are pushed down from Active Directory Group Policy.

Another way to do this is with Windows PowerShell. Like many other commands that are converted from DOS-based commands to PowerShell, there are more keystrokes. The equivalent commands to run as a PowerShell script could be run as in the following example:

$LocalGroup =[ADSI]"WinNT://Localhost/Administrators"
$UserNames = @($LocalGroup.psbase.Invoke("Members"))
$UserNames | foreach {$_.GetType().InvokeMember("Name", 'GetProperty', 
$null, $_, $null)}

Note: These scripts were adopted from examples at the PowerShell Code Repository.

The next time you need this information quickly for local groups, it will be a quick and easy script that you can easily export to a text file for archival and audit purposes.

Rick Vanover is an IT infrastructure manager for Alliance Data in Columbus, Ohio. He has years of IT experience and focuses on virtualization, Windows-based server administration, and system hardware.



WORTHWHILE?

1

1 votes
Blog

Talkback 0 comments

There are currently no comments for this post.


Guest user

Guest user

Level: 
Joined: —
Already a member? Log in »



 

Loading...

Whitepapers/Case Studies

Downloads

Windows Server News



Tech Jobs Now!

Tags

  1. computer
  2. database
  3. environment
  4. group policy
  5. hardware
  6. microsoft windows
  7. microsoft windows active directory
  8. microsoft windows powershell
  9. microsoft windows server
  10. microsoft windows server 2003
  11. microsoft windows server 2008
  12. network
  13. ohio
  14. rick vanover
  15. server
  16. server platforms
  17. servers
  18. storage
  19. tool
  20. virtualization