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

<#RemoveUserfromGroup.ps1
upnlist.txt = Contains list of user's UPN 
e.g. xyz@technpress.net
     xyz1@techpress.net 
<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.

guest
0 Comments
Inline Feedbacks
View all comments