Salaudeen Rajack

Salaudeen Rajack - Information Technology Expert with Two-decades of hands-on experience, specializing in SharePoint, PowerShell, Microsoft 365, and related products. He has held various positions including SharePoint Architect, Administrator, Developer and consultant, has helped many organizations to implement and optimize SharePoint solutions. Known for his deep technical expertise, He's passionate about sharing the knowledge and insights to help others, through the real-world articles!

3 thoughts on “SharePoint Online: Convert Folders to Metadata

  • Hi Salaudeen, Hope you are fine! can you please give a hint for the Sub folders as well, if I need to add Subfolders as choice column. thanks

    Reply
    • You mean, You want to use the Sub-Folder names as choices (Instead of Folders in the root of the library)? Use:

      #Parameters
      $SiteURL= “https://crescent.sharepoint.com/sites/PMO”
      $ListName = “ProjectList”
      $MetadataColumnName = “Project”

      #Connect to PnP Online
      Connect-PnPOnline -Url $SiteURL -Interactive

      #Get All Folders from the library
      $List = Get-PnPList -Identity $ListName -Includes RootFolder.Folders
      $Folders = $List.RootFolder.Folders

      $Choices = @()
      #Get 1st level Subfolders of the Folders in the library
      ForEach($Folder in $Folders | Where {$_.Name -ne “Forms”})
      {
      $SubFolders = Get-PnPProperty -ClientObject $Folder -Property Folders
      $Choices += $SubFolders | Select -ExpandProperty Name
      }
      #Get subfolder names as choices
      $Choices

      Reply
  • Thank you for sharing your knowledge.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *