0

I am trying to amend the Prog-ID on a Sharepoint folder so I can change it to a One note document.

Here is my code in CSOM, but it just says Prog-ID is read only, but I have read this can be done, any ideas ?

#Load SharePoint CSOM Assemblies
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"

##Variables for Processing
$SiteUrl = ""
$ListName=""
$FolderName=""
$UserName=""
$Password =""

#Setup Credentials to connect
$Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserName,(ConvertTo-SecureString $Password -AsPlainText -Force))


    #Set up the context
    $Context = New-Object Microsoft.SharePoint.Client.ClientContext($SiteUrl) 
    $Context.Credentials = $credentials

    #Get the List Root Folder
    $ParentFolder=$Context.web.GetFolderByServerRelativeUrl($ListName)

    $folderCollection = $ParentFolder.Folders


    $Context.load($folderCollection)
$Context.ExecuteQuery()



    foreach($folder in $folderCollection)
    {
        $folder.ProgId = “SharePoint.DocumentSet”
        $folder.Update()


    }
1

I have figured this out, ProgId IS READ ONLY so I used HTML_x0020_File_x0020_Type instead.. this is my sample code in CSOM.

Add-Type -Path “C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll”

Add-Type -Path “C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll”

Add-Type -Path “C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.WorkflowServices.dll”



# Specify tenant admin and site URL

$SiteUrl = ""


$UserName = ""

$SecurePassword = Read-Host -Prompt "Enter Password" -AsSecureString




$ClientContext = New-Object Microsoft.SharePoint.Client.ClientContext($SiteUrl)

$credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserName, $SecurePassword)

$ClientContext.Credentials = $credentials

$list = $ClientContext.get_web().get_lists().getByTitle('');


$ListItemCreationInformation = New-Object Microsoft.SharePoint.Client.ListItemCreationInformation
$ListItemCreationInformation.UnderlyingObjectType = [Microsoft.SharePoint.Client.FileSystemObjectType]::Folder
$ListItemCreationInformation.LeafName = "Beans Meanz Heinz "
$ListItemCreationInformation.FolderUrl = $list.RootFolder.ServerRelativeUrl
$listitem = $list.AddItem($ListItemCreationInformation)
$listitem["Title"] = "Beans Meanz Heinz"
$listitem["HTML_x0020_File_x0020_Type"] = "OneNote.Notebook"


$listitem.Update();
$ClientContext.ExecuteQuery()

Hope this helps someone who is banging there head with this.

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.