Forum Discussion

Mahmoud Ziada's avatar
Mahmoud Ziada
Copper Contributor
Jan 09, 2018
Solved

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...
  • VasilMichev's avatar
    VasilMichev
    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.

Resources