Hi,
Thanks for your question.
Also, the parameter "-members" of the cmdlet "Remove-ADGroupmember" cmdlet can accept Distinguished Name, GUID, Sid or samaccoutnname. Not the userprincipalname you used.
Best regards,
Young Yang
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi All
I have AD groups in csv file, i want to delete all the members of that groups. Will the below syntax help me.
Below is my csv file(there is space between Group and 01)
GroupName
Group 01
Group 02
Group 03
$groups=import-csv "C:\myadgroups.csv"
foreach($group in $groups)
{
Get-ADGroupMember -Identity $group.GroupName | %{Remove-ADGroupMember -Identity $group.GroupName -Members $_.userprincipalname -Confirm:$false}
}
If i need to delete group members for a single AD group will the below syntax help me.
Get-ADGroupMember -Identity "Group 01" | %{Remove-ADGroupMember -Identity "Group 01" -Members $_.userprincipalname -Confirm:$false}
If i need to delete AD groups will the below syntax help me
import-csv "C:\myadgroups.csv" | %{ Remove-ADGroup -Identity $_."GroupName" -Confirm:$false}
Hi,
Thanks for your question.
Also, the parameter "-members" of the cmdlet "Remove-ADGroupmember" cmdlet can accept Distinguished Name, GUID, Sid or samaccoutnname. Not the userprincipalname you used.
Best regards,
Young Yang