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}