Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do I administer local groups on a remote server with PowerShell and WMI? For example, I would like to add and remove domain AD groups from the "Remote Desktop Users" group.

This article provides a script for listing users while this article provides a bit more detail on the Get-WMIObject (GWMI) and Set-WMIObject (SWMI) cmdlets, however I'm unsure how to proceed with updating the group membership.

share|improve this question
as a starting point for this type of question go to – tony roth Oct 23 '12 at 14:44
And why are we using WMI/Powershell instead of GPOs/GPPs? – HopelessN00b Oct 23 '12 at 15:55
@HopelessN00b good point! – tony roth Oct 23 '12 at 16:41
up vote 2 down vote accepted

ADSI is your friend

$server = "somesServer"
$domain = "someDomain
$group2add = "group2add"
$localGroup = [adsi]"WinNT://$server/administrators,group"
$domainGroup = [adsi]"WinNT://$domain/$group2add,group"
share|improve this answer
Ok thanks. I also worked out how to list the members from this: $localmembers = @($localGroup.psbase.Invoke("Members")) $localmembers | foreach {$_.GetType().InvokeMember("AdsPath","GetProperty",$null,$_,$null)} – PeterX Nov 8 '12 at 0:19

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.