Question

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

Viktor

Was it helpful?

Solution

The following PowerShell script for your reference.

##Variables for Processing
$SiteUrl = "https://lz.sharepoint.com/sites/team"
$UserName="lz@lz.onmicrosoft.com"
$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"
$web.Update()
$ctx.ExecuteQuery()
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top