Skip to content

Instantly share code, notes, and snippets.

@SoPoCoder
SoPoCoder / PnP-PS-Scripts-Multichoice-To-Managed-Metadata-Copy.txt
Last active September 21, 2025 21:20
Copies multi-choice values from a SharePoint doclib/list source column and adds them (when present in the term store) as tags to a target column
# Copies choice values from a SharePoint document library source column and adds them (when present in the term store) as tags to a target column
# Will not increment version history or modify modified/modified by columns
# Define constants
$SiteUrl = "https://your-tenant.sharepoint.com/sites/site-name"
$ClientId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" # This should be the guid of your tenant's registered PnP Powershell module
$ListName = "Library Name"
$SourceColumn = "SourceColInternalName" # This field should be of type 'Choice' or 'MultiChoice'
$TargetColumn = "TargetColInternalName" # This field should be of type 'TaxonomyFieldType' or 'TaxonomyFieldTypeMulti'
$TermGroupId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" # The guid of the term group containing the tags that should be referenced
@SoPoCoder
SoPoCoder / PnP-PS-Scripts-Copy-Values-From-One-Col-To-Another-Col.txt
Last active October 10, 2025 13:19
Copies values from one SharePoint doclib/list source column to another column
#Function to copy values from one column to another in a list or document library (target column should be same type as source column)
#From https://www.sharepointdiary.com/2019/05/sharepoint-online-copy-values-from-one-column-to-another-using-powershell.html
#The account running the script needs to have edit permissions to the site or library
#Define constants
$SiteUrl = "https://your-tenant.sharepoint.com/sites/site-name"
$ClientId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" # This should be the guid of your tenant's registered PnP Powershell module
$ListName = "Library Name"
$SourceColumn = "SourceColInternalName"
@SoPoCoder
SoPoCoder / PnP-PS-Scripts-Update-Col-Values
Created October 10, 2025 13:27
Generic script to loop through rows of a SharePoint list/library to make modifications to column values
#Generic script to loop through rows of a SharePoint list/library to make modifications to column values
#Define constants
$SiteUrl = "https://your-tenant.sharepoint.com/sites/site-name"
$ClientId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" # This should be the guid of your tenant's registered PnP Powershell module
$ListName = "Library Name"
#Connect to SharePoint Online site
Connect-PnPOnline $SiteUrl -Interactive -ClientId $ClientId