A group or contact needs to be deleted from 365 using PowerShell but remove-msolcontact or group doesn't work.


Groups or contacts need to be removed by using the object ID.


As a customers 365 tenancy may include hundreds or possible thousands of groups it's best to export a list of them all to your local machine.

Login to their 365 tenancy using Azure PowerShell and change the root folder location to one on your local machine, in the example below it's going to a folder on the C drive names IAM Cloud.

You can do this by using the command cd C:\IAM Cloud


Then use one of these commands:

get-msolgroup -all | export-csv Dundalkgroups.csv –NoTypeInformation

get-msolcontact -all | export-csv Dundalkcontacts.csv –NoTypeInformation

Name the .csv something relevant to the customer.


This will save to the local folder:


From the spreadsheet delete any columns that you don't need and find the correct group or contact either by display name or email address:


Then the command you need to run is remove-msolgroup -objectID 'insert object ID' or remove-msolcontact -objectID 'insert objectID'.

This will permanently remove the group or contact.