I was setting up a custom domain within Azure. After I added the TXT record to our DNS to verify ownership, it gave me the following error message.
To do this in PowerShell, we’re going to install the Azure ActiveDirectory (MSOnline) Module:
install-module MSOnline
Connect-MsolService:
Connect-MsolService
Remove-MsolDomain:
Remove-MSolDomain -DomainName safetonet.com
I was greeted with the following error.
I then ran the Get-MsolUser command as the error suggested.
Get-MsolUser -DomainName safetonet.com
But this returned nothing.
You need to remove the users, groups and XXXX before being able to remove the domain.
View and Remove Groups
Within the Office 365 portal, I wasn’t able to delete the group that existed for the domain.
View Groups
But by running the Get-MsolGroup command, I can see all the groups in the account:
Get-MsolGroup
I can see the group that exists within the domain, and can take note of the objectid
to use with the remove command Remove-MsolGroup.
Remove the Group Object
Remove-MsolGroup -Objectid '9b1aer67-11x4-4398-b8cb-330b923f3016'
Delete the Domain
Now we have deleted all the resources in the domain. We can again use the Remove-MsolDomain command to delete our Domain.
Remove-MSolDomain -DomainName contoso.com
I have been working in software development for over 16 years, during that time I have worn many hats.
I have worked as a Software Engineer, Architect, Agile Coach and Trainer. I’ve created teams, I’ve lead teams, but my main goal is to help teams build great software and enjoy the process.
I help a whole range of businesses – from startups with just an idea who want to build a team to take that idea into reality and FTSE 100 businesses who need to optimise existing teams – I train, mentor and coach them to success.
If you happen to know of anybody who could benefit from results like this, then please go to my contact page and get in touch.
Owen Davies