Add values to folder columns in a SharePoint Online document library with PowerShell

Jairo Javier Baleta Cali 286 Reputation points
2024-03-07T19:18:44.04+00:00

I have a library in which custom columns were added but I have not been able to add the corresponding values when creating the folder or modify it once the folder is created in SharePoint Online. For example:

Captura de pantalla 2024-03-07 140926

I have verified with the Add-PnPFolder and Resolve-PnPFolder commands but it does not provide options to be able to add the values to the columns established in the SharePoint library with PowerShell.

I hope you can help me.

Thank you so much.

Microsoft 365 and Office SharePoint For business Windows
Windows for business Windows Server User experience PowerShell
0 comments No comments
{count} votes

Accepted answer
  1. Ling Zhou_MSFT 23,620 Reputation points Microsoft External Staff
    2024-03-11T06:37:24.49+00:00

    Hi @Jairo Javier Baleta Cali,

    Please try this PowerShell:

    #Parameters
    $SiteURL = "https://wendytest123.sharepoint.com/sites/karley03"
    $ListName = "Lib1"
    $FolderServerRelativeURL = "/sites/karley03/Lib1/Folder1"
     
    #Connect to SharePoint Online site
    Connect-PnPOnline -Url $SiteURL -Interactive
     
    #Get the Folder
    $Folder = Get-PnPFolder -Url $FolderServerRelativeURL -Includes ListItemAllFields
     
    #Update Folder's column
    Set-PnPListItem -List $ListName -Identity $Folder.ListItemAllFields.Id -Values @{"CusColumn1" = "XXXXXXXXX"; "CusColumn2" = "XXXXXXX"} | Out-Null
    
    

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


1 additional answer

Sort by: Most helpful
  1. Ling Zhou_MSFT 23,620 Reputation points Microsoft External Staff
    2024-03-08T03:00:41.1166667+00:00

    Hi @Jairo Javier Baleta Cali,

     This is a default behavior of SharePoint, you cannot assign custom columns to the (default) Folder content type in library. You must have added custom column to the Document content type in library.

    Workaround:

    You can set custom columns for folders in Grid view. Open your library in grid view using Edit in grid view option at the top of library.

    User's image


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.