Powershell: Issue with Connect-SPOService

Assuming, SharePoint Online Management Shell is installed..

First step to manage SharePoint Online tenant is connecting to the tenant. However, the following is a common error that occurs while connecting to tenant (SPO Connection) using “Connect-SPOService” Powershell command. I encountered this error when in the early days of the SharePoint online management shell. Surprisingly this still persists with the latest version. So wanted to summarize the findings.

Symptoms:

PS C:\WINDOWS\system32> Connect-SPOService -Url "https://organizationname-admin.sharepoint.com" -Credential $creds

Connect-SPOService : For security reasons DTD is prohibited in this XML document. To enable DTD processing set the

DtdProcessing property on XmlReaderSettings to Parse and pass the settings into XmlReader.Create method.

At line:1 char:1

+ Connect-SPOService -Url "https://organizationname-admin.sharepoint.com" -C ...

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ CategoryInfo          : NotSpecified: (:) [Connect-SPOService], XmlException

+ FullyQualifiedErrorId : System.Xml.XmlException,Microsoft.Online.SharePoint.PowerShell.ConnectSPOService

Observations from Fiddler Trace:

  • A get request sent for https://msoid.organizationname.onmicrosoft.com/FPUrl.xml has been responded with content of type “text/html” instead of a valid “XML”. The role of “FPUrl.xml” is unknown.DTD Error_Fiddler
  • The returned html(in the above step) is from my ISP saying, the specified URL is not found.ISP-Response-MSOID
  • Got similar response when tried directly in the browser.
  • Another interesting thing here is – msoid, a CNAME record required at the External DNS. This is to direct the user to best server for auth-process to facilitate faster authentication response. This is not going to solve my issue, as I don’t have any custom domain. Moreover, MS’s documentation states this as requirement only for O365 operated by “21Vianet” – which, again, is not my case.(Click to See Adding DNS entries for GoDaddy)

Error Message:

  • DtdProcessing of XmlReaderSettings: Nothing to do with this setting as we do not explicitly handle the XML in our script.

Solution (1): A straight forward option to go with Web Login. This is said to be the only way when MFA is enabled, however, this comes to the rescue with this issue too.
Execute without passing the credentials..

PS C:\WINDOWS\system32> Connect-SPOService -Url "https://organizationname-admin.sharepoint.com"

This will pop a web form prompting for credentials. Once we login, it works without any issue.

Solution (2): Configure Google’s public DNS server for IPv4. This will resolve the issue. This solution is also suitable, in case the error source is a CSOM code.

DTD Error

Note: For IPv6, corresponding IPv6 value of Google’s DNS should work.