We have an issue when attempting to use the Document ID service in SPO with some documents. We're able to browse to the majority of them using the DocIdRedir URL
https://contoso.sharepoint.com/sites/sitename/_layouts/DocIDRedir.aspx?ID=CTO-12345-6789
With others, when we try and browse to the document using the DocID Url, we're told that there is no document with that ID.
What we've found is that if we make a small change to a doc with the issue SPO seems to re-crawl it and we can then browse to the document using the ID.
The issue is we would like to avoid having to manually make small changes to all documents as not all are affected. We would like to be able to generate a report of the affected documents using PShell. We were thinking of doing something like using invoke-webrequest or invoke-pnprestmethod and then looking for the text within the returned HTML that says "No document with that ID"
e.g.
invoke-webrequest https://contoso.sharepoint.com/sites/sitename/_layouts/DocIDRedir.aspx?ID=CTO-12345-6789
but this returns HTML indicating a sign-in is needed
or
'invoke-pnprestmethod 'https://contoso.sharepoint.com/sites/sitename/_layouts/DocIDRedir.aspx?ID=CTO-12345-6789' -Connection (get-pnpconnection) -raw'
but this returns an "Object moved" error regardless of if the doc has the issue or not.
The issue seems to be that MFA is in place so using either of the above requires sign-in and doesn't return us the error page we would hope to be able to base our report on.
Is there a better method of achieving my goal or is there some way of combining the two PShell commands with a sign-in so that we return the error page for the affected docs instead of a page that wants us to sign in?
Thanks