I have tried to use multiple methods for domain deletion. But the exceptions thrown leave me clueless.
This is the domain information under Microsoft Graph PowerShell.
Get-MgDomain
Id AuthenticationType AvailabilityStatus IsAdminManaged IsDefault IsInitial IsRoot IsVerified Manufacturer Model PasswordNotificationWindowInDays PasswordValidityPeriodInDays SupportedServices
-- ------------------ ------------------ -------------- --------- --------- ------ ---------- ------------ ----- -------------------------------- ---------------------------- -----------------
deathknight0718qq.onmicrosoft.com Managed True False True True True 14 2147483647 {Email, OfficeCommunicationsOnline, MoeraDomain}
foliagecn.onmicrosoft.com Managed True False False True True 14 2147483647 {Email, OfficeCommunicationsOnline, MoeraDomain}
When I run Remove-MgDomain, it throws clueless exceptions.
Remove-MgDomain -DomainId foliagecn.onmicrosoft.com
Remove-MgDomain : Domain deletion attempt failed.
所在位置 行:1 字符: 1
+ Remove-MgDomain -DomainId foliagecn.onmicrosoft.com
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: ({ DomainId = fo...m, IfMatch = }:<>f__AnonymousType132`2) [Remove-MgDomain_Delete1],RestException`1
+ FullyQualifiedErrorId : Request_BadRequest,Microsoft.Graph.PowerShell.Cmdlets.RemoveMgDomain_Delete1
Same as Force Delete
Import-Module Microsoft.Graph.Identity.DirectoryManagement
$params = @{ DisableUserAccounts = $true }
Invoke-MgForceDomainDelete -DomainId foliagecn.onmicrosoft.com -BodyParameter $params
Invoke-MgForceDomainDelete : Domain deletion attempt failed.
所在位置 行:1 字符: 1
+ Invoke-MgForceDomainDelete -DomainId foliagecn.onmicrosoft.com -BodyP ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: ({ DomainId = fo...ionJsonSchema }:<>f__AnonymousType90`2) [Invoke-MgForceDomainDelete_Force1],RestException`1
+ FullyQualifiedErrorId : Request_BadRequest,Microsoft.Graph.PowerShell.Cmdlets.InvokeMgForceDomainDelete_Force1
When I go to entra.microsoft.com to remove it, it throws the same exception message.
There is only one user for the entire cloud.
Possible causes were found by themselves:
You can't remove the ".onmicrosoft.com" domain from your account. When you remove a domain, user accounts will revert back to the ".onmicrosoft.com" address as the Primary SMTP/UserprincipalName.