Summary

 

I'm trying to delete a group and a contact from Office 365 using Azure PowerShell by using Remove-MsolGroup -userprincipalname -example@example.com, but it's not working.




Cause


To delete a contact or group from Office 365 you have to use the object ID.




Solution


You obtain the object IDs of all your groups/contacts by using get-msolgroup -all / get-msolcontact -all.


They can also be exported to a .csv using get-msolgroup -all | export-csv groups.csv.


Then the command to delete is remove-msolgroup (or contact) -objected ****insert objectID****.