Remove Active Directory Group from a list of AD users using Powershell

<#RemoveUserfromGroup.ps1
upnlist.txt = Contains list of user's UPN 
e.g. [email protected]
     [email protected] 
<GroupName> = This group will be removed 
from the user's mentioned in the upnlist.txt file #> 
$upnlist = Get-Content 'c:\temp\upnlist.txt' 
Foreach ($upn in $upnlist) 
{ $var = Get-ADUser -Filter "UserPrincipalName -eq '$upn'"
Remove-ADgroupmember -identity '<GroupName>' -members $var -Confim:$false }
guest
0 Comments
Inline Feedbacks
View all comments