How to Delete Security groups from a CSV

Office 365 Security Owner todayJuly 29, 2019 10

Background
share close

If you have created security groups in large number by using CSV you need to make a script to delete those groups from a CSV.  

In order to take the action of delete, you need cmdlet because this only works with ObjectId.  To use any other parameters you need to run the following:

Get-MsolGroup | ? {$_.DisplayName -eq “test”}

For designating the groups, you need a field NAME in the CSV file.

It “must” be unique, or you will delete several other groups with no option of recovery.

Another formula can be as follows:

Import-Csv blabla.csv | % { Get-MsolGroup -SearchString $_.Name | Remove-MsolGroup}

Written by: Owner

Rate it

Previous post