Add or remove AD groups to or from Local groups
02-09-2011
Downloads: 540
File size: 1.1kB
Views: 3,096
Embed
 |
Add or remove AD groups to or from Local groups |
- <
- Name: remove-ad-group.ps1
- Objective: To read a list of computernames from a file and then if the identified
- group exists in the local administrators group remove it
- Date: 01/31/2011
- Email: rburke@rbconsulting.net
-
-
- $userName = 'IS_Tier3'
-
- $localGroupName = 'Administrators'
-
- $c = Get-Content "c:\Servers.txt"
-
- foreach ($comp in $c)
- {
-
- $computerName = $comp
-
- [string]$domainName = ([ADSI]'').name
-
- $confirm = "Y"
- if ($confirm -eq "Y") {
- ([ADSI]"WinNT://$computerName/$localGroupName,group").remove("WinNT://$domainName/$userName")
-
- Write-Host "User $domainName\$userName has been removed from local group $localGroupName on computer $computerName."
- }
- }