Manage group membership using these scripts

 

Summary

When managing permissions, best practice dictates that you use groups in lieu of explicit user account assignments. Here are some options for Windows admins.

Events

Echelon 2012
June 11 and 12, 2012

University Cultural Centre, National University of Singapore

Startup Asia Jakarta 2012
June 7 and 8, 2012

12th Floor, Annex Building, Wisma Nusantara Complex, Jl. M.H. Thamrin No. 59 Jakarta 10350, Indonesia

MMA Forum Singapore
April 23-25, 2012

Grand Hyatt Singapore

Nothing can irritate me more than seeing a littering of user accounts in the local group inventories on a server. The Remote Desktop Users, Power Users, and Administrators local groups can be restricted groups for servers depending on many situations. I don't have an issue with the permissions assigned; let's face it--we all need to do our jobs. The issue is how we get there.

Here are a few ways Windows administrators can drop in group memberships via script. The first one is for the old-school net command administrator in all of us:

net localgroup Administrators /Add RWVDEV\SelectAdmins

In the example, the Administrators local group has the domain group RWVDEV\SelectAdmins added to its inventory. You can go the PowerShell route as well for the same command and introduce the option to perform the task on a remote computer:

$computerName = 'baselinews2k3-2.rwvdev.intra'
$userName = 'SelectAdmins'
$localGroupName = 'Administrators'
$domainName = 'RWVDEV'
if ($computerName -eq "") {$computerName = "$env:computername"}
[string]$domainName = ([ADSI]'').name
([ADSI]"WinNT://$computerName/$localGroupName,group").
Add("WinNT://RWVDEV/$userName") Write-Host "User $domainName\$userName is now member of local group
$localGroupName on $computerName."

Note: This PowerShell script was adapted from this PowerShell.com post.

This script will perform the same task and can be pushed to a remote computer (in this example, it was sent to the baselinews2k3-2 server). Also, the $userName variable can be a group name instead of an explicit user.

In addition, Group Policy can manage restricted group membership and push to domain computers via Group Policy Objects (GPOs). But, inevitably, there are scenarios where you may need to manage individual systems in lieu of creating GPOs.

If you have other ways of managing membership via scripts, let us know in the discussion.

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

Talkback

Add your opinion

In order to post a comment, you need to be registered. (Sign In or register below)

Post your comment

ZDNet Asia Live

China solar cell makers seek Taiwan partnerships http://t.co/p5Hh7kJD

Big data acquisitions pave way to fast, effective innovation http://t.co/hdiEfBsz via @zdnetasia

Integration, focused investments to propel Windows Phone: By Kevin Kwang , ZDNet Asia on May 23, 2012 (2 hours a... http://t.co/E7tsZbHJ

Integration, focused investments to propel Windows Phone http://t.co/u9TqjQ8C

ZDNet Asia IT Salary Benchmark 2012 http://t.co/rVwYlV7H

AsiaClassifiedToday. Integration, focused investments to propel Windows Phone - ZDNet Asia: S... http://t.co/47tdjZyG #asia #google #biz

Malaysian organizations are apathetic about information security and fail to realize they are potentially under... http://t.co/XeuvbXrs

Big data acquisitions pave way to fast, effective innovation - ZDNet Asia News http://t.co/vDZpl0lu

"Big data acquisitions pave way to fast, effective innovation" including @Vivisimo_Inc (client) in @ZDnetAsia http://t.co/yNSdPqbb

Homegrown smartphone OSes gaining favor in China: 59 Jakarta 10350, Indonesia Locally-made mobile operating syst... http://t.co/BruP98Es

RT @MDMGeek: Big data acquisitions pave way to fast, effective innovation - ZDNet Asia http://t.co/ky8YgPAn #Bigdata #analytics via @ciropuglisi

Integration, focused investments to propel Windows Phone http://t.co/6JkDa9sB

RT @AsianFashionLaw: Malaysia offers some manufacturing benefits over China http://t.co/bMquIFiX

Acquisitions in the Big Data market increasingly important to enterprises… http://t.co/Br4BkXyZ

Experience trumps content in apps monetization http://t.co/iaCY5ebX

So much as we know , MTK6575 extremely integrated frequency1GHz ARM Cortex-A9 processor, the superiority of 3G / HSPA Modem, and help the...

1 day ago by y15822137359 on 5 SaaS adoption speed bumps to avoid

I reckon your view: "CRM is strategy, not software", if a company replicating the approach uses in ERP implementation into CRM, what they...

2 days ago by wykoong on Gartner: Mobile CRM gives better ROI than social

This video will teach you about the Excel fill handle but also provide you with a workook to download... http://www.youtube.com/watch?v=...

3 days ago by TradeBrother on A quick fill handle trick for Microsoft Excel

waiting...

5 days ago by eapete on What should count in a company's market value?

Boy, you've opened a can of worms now.

Wait for the rants & raves.

5 days ago by eapete on What should count in a company's market value?

I was puzzling before this whether to replicate the success formula we executed for a financial institute, and come out with a standard s...

5 days ago by wykoong on Drop the egos, copy ideas, then innovate