I'm trying to clean all users from Local Group test_group by executing the following command below on Windows 2008 R2 Standard, PowerShell 2.0.
Get-ADGroupMember "test_group" | ForEach-Object {Remove-ADGroupMember "test_group" $_ -Confirm:$false} It throws the following error, most probably because I'm using v2.0?:
The term 'Get-ADGroupMember' is not recognized as the name of a cmdlet, function, script file, or operable program. Che ck the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:18 + Get-ADGroupMember <<<< "test_group" | ForEach-Object {Remove-ADGroupMember "test_group" $_ -Confirm:$false} + CategoryInfo : ObjectNotFound: (Get-ADGroupMember:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
I tried many ideas from this article and its comments, and I couldn't get any to work but I'm not a sysadmin and I'm not sure if I'm not missing something?: http://blogs.technet.com/b/heyscriptingguy/archive/2009/07/28/hey-scripting-guy-how-do-i-remove-all-group-members-in-active-directory.aspx
Please help, I have around 300 groups to clean on Monday and I don't want to do it manually...