I am looking for a script to enable DocID and set a Prefix. Found this solution here: http://blog.repsaj.nl/index.php/2015/04/o365-enable-document-id-and-set-prefix-via-csom/ .

But how bind into a PowerShell script?

Thanks in Advance



The following PowerShell script for your reference.

##Variables for Processing
$SiteUrl = "https://lz.sharepoint.com/sites/team"
$Password ="xxx"

Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll" 
Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"

#Setup Credentials to connect
$Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserName,(ConvertTo-SecureString $Password -AsPlainText -Force))
#Setup the context
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$ctx.Credentials = $Credentials
$web = $ctx.web
$props = $web.AllProperties
$props["docid_msft_hier_siteprefix"] = "MYPREFIX"
$props["docid_enabled"] = "1"
  • Working great! Thanks! – Viktor Graf Apr 30 '19 at 6:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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