Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Remove-ADGroupMember

$
0
0

I am trying to remove a machine account from an AD group.  I have this code:

$pc='MG09780'
foreach ($machinein$pc) { remove-adgroupmember-identity'MG.AppUpToDate'-member$machine-Confirm:$false}

I've noticed that remove-adgroupmember does not have a search filter and it seems to want one.  when I run the above command I get the following error:  remove-adgroupmember : Cannot find an object with identity: 'MG09780' under: acme.org

now the machine in question of course is there and it is active.  It is also a member of MGAppUpToDate.   

And what I really need to do is read All AD Group membership and delete everything "except" Domain Computers and a group called MG.Wireless (if MG.Wireless exists)  

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles