Forum Discussion
Mahmoud Ziada
Jan 09, 2018Copper Contributor
Remove bulk security groups using PowerShell
Hi All
I've created security groups in bulk using CSV.
I am trying to make a script to delete security groups from a CSV but not going anywhere:
Let's say I have security groups "NewGro...
- Jan 10, 2018
Without sharing the CSV file we can only guess. For example something like this should work:
Import-Csv blabla.csv | % { Get-MsolGroup -SearchString $_.Name | Remove-MsolGroup}
That's assuming you have a field NAME in the CSV file, designating the groups. It *must* be unique, otherwise you might end up deleting a bunch of other groups. And there is no recover delete group option, so use with care.
Jan 09, 2018
What about using the former CSV to get the Groups you want to delete and actually delete it?
Mahmoud Ziada
Jan 10, 2018Copper Contributor
That's exactly what I am trying to do.
I want to be able to edit the csv file, adjust it to what needs to be deleted (that will be in hundreds probably) then run the script.
Any ideas?