Follow these simple steps to convert a domain to a federated domain. Take precaution to run the windows powershell from the desktop shortcut. Right click the desktop shortcut and 'Run as administrator'.
$cred=Get-CredentialConnect-MsolService -Credential $credConvert-MsolDomainToFederated -DomainName xxxx.com -SupportMultipleDomain
In Step 3, if you dont have multiple domains in AD then you can leave out the SupportMultipleDomain switch