SharePoint – Adding keywords to documents with PowerShell

Ever needed to replace or add keywords to documents in a SharePoint site?
Recently I was in charge of migrating site collections from a on-premise environment to SharePoint online.

After the migration we needed to replace a certain taxonomy keyword on all documents. So I created a small PowerShell function to facilitate the company to do so. The function takes 5 parameters:

  • Url
    • URL to the site collection.
  • Credential
    • Credentials to contact the site collection.
  • TermGuid
    • The guid of the keyword that you want to find.
  • AddTermGuid
    • The guid of the new keyword you want to add/replace.
  • Replace (switch)
    • If this switch is set, it will substitute TermGuid with AddTermGuid

In order for the function to work you need to download the SharePoint PnP cmdlets here.

You are able to get the SharePoint taxonomy keyword GUID through the Get-PnPTerm cmdlet, find more information here.

Experienced advanced operations engineer with a demonstrated history of working in the information technology and services industry. Skilled in Windows Server, Azure, Ethical Hacking, Office 365, Exchange, Jenkins, SCCM, Octopus Deploy and PowerShell to name a few. Strong engineering professional with a big passion for knowledge.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.