0

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

3
  • How new are the documents that are affected? Is it possible that they have not been crawled yet? Commented Oct 11, 2022 at 22:04
  • Hi, The documents have been present in SPO for a few days. Most of them work fine, just a subset experience the issue. I also confirmed the affected documents had been crawled using PnP commands to view the crawl logs. Thanks
    – James
    Commented Oct 12, 2022 at 9:45
  • If you're certain there is a document that exists with that DocID and the DocID URL still doesn't work after a few days, then you're probably best talking to Microsoft support. This sounds like server side problem, so it's out of our control. Commented Oct 12, 2022 at 9:51

1 Answer 1

0

Try using the PNP PowerShell Module: https://pnp.github.io/powershell/

To connect: Connect-PnPOnline (either supply credentials or -Interactive for MFA.

To search: Submit-PnPSearchQuery

$results = Submit-PnPSearchQuery -Query "DlcDocId:{___DOCUMENT_ID___}"

This will return a Object with lots of properties to include "RowCount" and "ResultRows", which has a subset of the fields associated with a file object.

If I understand your problem correctly, check to see if $results.RowCount -eq 1 to find your document that has not been changed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.