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!

25 thoughts on “SharePoint Online: Bulk Update Metadata Properties from a CSV File using PowerShell

  • Hi Salaudeen, nice guide.
    Why does Connect-PnPOnline – interactive prompt me to grant seemingly ALL permissions ?
    As soon as I run “Connect-PnPOnline $SiteURL -Interactive” it opens up a browser window and asks me to request approval for these below permissions? (I haven’t posted all of them)

    Create, read, update, and delete your tasks and task lists
    Read all transcripts of online meetings.
    Access the PowerApps Service API
    Access Common Data Service as you
    View all datasets
    Read activity data for your organization
    Read service health information for your organization
    Read and write managed metadata
    Have full control of all site collections
    Read and write user profiles

    Reply
  • Hello there,

    Do you have a version of this script that updates the metadata of folders instead of files?
    Any suggestions would be appreciated.

    Thanks,

    Dan

    Reply
  • Hi There,
    I was wondering if I could use this script to update the metadata on a folder instead of a file.
    Would it just be a matter of replacing the file name in the csv to the folder and changing the get-pnpfile to get-pnpfolder? Any suggestion would be appreciated.

    Reply
  • Hi! A quick question:
    Based on your script how would you update a Managed Metadata Field with the hashtable ?
    In which format do you have to save to value to the key? I’m guessing you would use the field’s internal name as key, but what would be the value?

    Reply
  • Hi Salaudeen, thanks for the script.
    However, I have one problem.
    I would like to update a MultiChoice field with several values
    Is this possible?
    Many thanks, Kevin

    Reply
      • How do you write that in the excel file, i dont get the multicoice to work

        Many thanks Per

        Reply
          • I saw that but if you for exameple as in you excel sheet has a row PMO|Classification|IT and PMO|Classification|HR that should be a multivalue how do you specify that?

            Regards
            Per

            Reply
            • Wrap them in double-quotes: E.g., “PMO|Classification|IT”,”PMO|Classification|HR”

              Reply
              • @Salaudeen – For some reason wrapping the multiple term values in quotes only causes the overlay to cancel with the following message: “WARNING: Unable to find the specified term. Skipping values for field ‘Department’.”

                I have experimented with various delimiters and have had no luck.

                The following only fails when the CSV for “Department” field is setup in the following way:
                “People|Department|Manager”,”People|Department|Director”

                The following works fine if run individually, but this will not allow me to multi-select for the two terms:
                People|Department|Director
                People|Department|Manager

                Thank you for this fantastic resource. Your input would be greatly appreciated!
                -=Adam

                Reply
      • Many thanks – that works

        Reply
  • Hello!
    Can’t understand what’s wrong in the code.

    Getting next eror:
    Get-PnPField: C:\Scripts\svlibmetadata.ps1:33
    Line |
    33 | $ListFields = Get-PnPField -List $ListName | Where { (-Not ($_.Re …
    | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    | The remote server returned an error: (400) Bad Request.

    Could not find File at /sites/svlib/Shared%20Documents/sv_3dss-1.33_install-config-guide__en_core_20220530.pdf , Skipped!
    Could not find File at /sites/svlib/Shared%20Documents/sv_ip-3.0_admin-guide__en_core_20220527.pdf , Skipped!

    Reply
  • Hi – I need to update the Created By (Author) field on 2500 lines on a SharePoint Online list. I need to change from LastName, First Name format to email address. I am migrating a list from on-prem to SharePoint Online that allows a user to view only those items that they created. But since moving to Office 365 the usernames are different and therefore nobody can see their list items.

    I can update one list item using this link and specifying the ID of the item but this will take forever.
    https://www.sharepointdiary.com/2016/11/update-created-by-modified-by-created-at-modified-at-values-using-powershell.html

    I also tried the above guide and had 3 columns in my csv, FileName, ServerRelativePath and Author like below:

    FileName ServerRelativeURL Author
    1_.000 /sites/EngineeringDevelopment/Lists/CPD_O365/1_.000 email@company.com

    Looks like its updating the list item but not the Author – not sure what’s being updated. It shows the below line on all 2500 lines in powershell – should I be seeing the updated value after values: below

    Updating Metadata of the File ‘2538_.000’ at ‘/sites/EngineeringDevelopment/Lists/CPD_O365/2538_.000’ with values:

    Reply
  • I am also having this issue and would like to know if there is a fix.

    Thank you

    Reply
  • Hi, the script looks very promising. However when I use it I get the below error. Any ideas how to fix this? Thanks. Cheers, Sander.
    Set-PnPListItem : Invalid request.

    At C:tempImportMetaDataProperties.ps1:74 char:13

    Set-PnPListItem -List $ListName -Identity $File.Id -Value …

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    CategoryInfo : WriteError: (:) [Set-PnPListItem], ServerException

    FullyQualifiedErrorId : EXCEPTION,PnP.PowerShell.Commands.Lists.SetListItem

    Reply
  • Hi, I had the same issue until I replace ; with , as a delimiter in the CSV file. Cheers, Sander.

    Reply
  • Hi how I can use to tag a metadata to the respective file when I upload it using Add-PnPFile ? In Powershell ?

    Reply
  • Hey! Do you have a pnp powershell to update Title from Filename (with no file extension) in SharePoint Online document library so that the name and title columns will have the same value across all files in the document library. Thanks a lot!

    Reply
  • I have a metadata.csv file with columns where there is no data for a few rows. The code errors out if a field is blank. How to modify the code to accept blank fields.

    Reply
  • I am unable to maintain modified date and modified by as -systemupdate is not worming with Set-PnPListItem -List $ListName -Identity $file1.ID -Values @{“RetentionDate” = $RetentionDate} -SystemUpdate any idea

    Reply
  • Great! Script works like a charm!

    Reply
  • Hi, Thank you for this script!
    I am getting the following error: Get-PnPFile : Cannot bind argument to parameter ‘Url’ because it is null.
    My CSV file does have urls’s under the ServerRelativeURL column.
    Please assist.

    Reply
    • does your CSV file has ‘ServerRelativeURL’ field with valid server relative URLs? E.g. /sites/sales/docs/document.docx? “-ErrorAction SilentlyContinue” should suppress the issue and pass-on..

      Reply

Leave a Reply

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