Skip to main content

Posts

Showing posts with the label Library

Update List Items : Replace a value in a field which contains some text(URL in this case)

Consider a scenario wherein you need to replace a part of value in single line of text. 1) Fetch List Items based on a particular condition using CAML Query Eg: Get all list items where status = "In Progress" and Content Type ="My Content" 2) From the list items returned by CAML query, modify and replace a particular string from a value. 3) Column type is single line of text Add-PSSnapin Microsoft.Sharepoint.Powershell cls #Log Variables $LogFolderPath = "C:\Logs\"  # LogFolderPath # Text File Path $LogFilePath = $LogFolderPath+ "txtLog_WF_UPDATE_"+(Get-Date).ToString("MM_dd_yyyy_hh_mm_ss")+".txt" # CSV Log File Path with current time stamp $CSVLogFilePath=$LogFolderPath+ "CsvLog_WF_UPDATE_"+(Get-Date).ToString("MM_dd_yyyy_hh_mm_ss")+".csv" #SP variables $web=$null ; $list=$null; $SiteURL = "http://mysharepointsite:30042/sites/en-us"# Library Site Url $ListName =...

SharePoint Script to update MMD Column in Library

This post contains the code to update Managed Metadata column value in Library. Add-PSSnapin Microsoft.Sharepoint.Powershell cls #Log Variables $basePath = split-path $SCRIPT:MyInvocation.MyCommand.Path -parent Set-Location $basePath #SP variables $web=$null ; $list=$null; $SiteURL = "https://mysharepointsite/en-us"# Library Site Url $ListName = "Pages";# List Name $FieldName="Document" $termStoreName = "Managed Metadata Service Application" $termGroupName = "Document_Content" $termSetName = "DocumentName" $MMDValueToUpdate = "Technical Doc" #Pre-requisite checks Try {     #Web Check     $web = Get-SPWeb $SiteURL     if($web -eq $null)     {       Write-Host "Cannot find an SPSite object that contains the following Id or Url: $SiteURL"  $_.Exception.Message        Exit     }     #List Check     $list = $web.Lists[$ListName]     if($...