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

upnlist.txt = Contains list of user's UPN 
<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 }
Subscribe to Stay Connected

Thank you for visiting TechPress πŸ‘. When you subscribe to the blog, email notification βœ‰ will be sent to you when a new blog post is published. You can unsubscribe at any time.

Inline Feedbacks
View all comments