How to Get or Set SharePoint Document ID _dlc_DocId using PowerShell

SharePoint Document Id

Document Id is something which SharePoint internally assigns to documents and maintains a uniqueness for each document.

This Document Id never changes even if the document is moved anywhere else and so can be used as a bookmark to the document.

Just in case you want to access the DocId value or want to change it (not recommended though !!), you can refer to the the internal SharePoint column _dlc_DocId.

Get Doc Id value for a document


Set Doc Id value for a document

$item["_dlc_DocId"] = "NewId-12345"

Here is a complete example using PowerShell to access and modify the Document Id

PowerShell script to get and set the Document Id (_dlc_DocId) column

$web = Get-SPWeb http://SharepointSiteUrl
$list = $web.lists["Shared Documents"]

//Get handle of item by ItemId
$item = $list.getitembyid(1)

//Get the Document Id using column _dlc_DocId

//Checkout before making changes

//Set the Document Id using column _dlc_DocId
$item["_dlc_DocId"] = "NewId-12345"
$item["_dlc_DocIdUrl"] = "http://SharePointSiteUrl/_layouts/DocIdRedir.aspx?ID=NewId-12345, NewId-12345"

//Check in once changes are completed
$item.File.CheckIn("DocId changed and document checked in")

Note- Once the Document Id is modified, a search crawl (incremental is sufficient) is required in order to associate the changes with the document, else you will get errors when clicking on the Document Id.


  • I tried this in my SharePoint Online tenant site, but not working. Can you share updated code for Online Management Shell ? Im using Document ID and came across a case where need to change it.
    anon 13 Mar 2020 20:00:04 GMT
  • not working in SharePoint Online
    anon 27 Jan 2019 05:12:10 GMT
  • Further comments disabled!

Try Out Code2care Dev Tools:


Android Java Linux Microsoft Google Python macOS Notepad++ Microsoft Teams CSS PHP SharePoint Html Linux C Programs Bootstrap jQuery Sublime Android Studio Facebook Eclipse WhatsApp News MySQL Json HowTos JavaScript FTP S3


Code2care is an initiative to publish and share varied knowledge in programming and technical areas gathered during day-to-day learnings and development activities.

Students and Software Developers can leverage this portal to find solutions to their various queries without re-inventing the wheel by referring to our easy to understand posts. Technical posts might include Learnings, Tutorials, Trouble-Shooting steps, Video Tutorials, Code Snippets, How Tos, Blogs, Articles, etc.
🎉 We are celebrating the 10th years of Code2care! Thank you for all your support! We hope we made a difference.
We strong support Gender Equality & Diversity.

We stand in solidarity with Ukraine - Make a donation to UNHCR -