My Client needed was to assign a value to the "Title" property, we decided to loop through all the documents and assign "Title" from "Name". Here is a sample of that script.
# Load SharePoint library
[system.reflection.assembly]::LoadWithPartialName("Microsoft.Sharepoint")
# Connect to the site collection http://SP2010Server:1212 and store the object in the $site variable
$site = New-Object Microsoft.SharePoint.SPSite("http://SP2010Server:1212")
# Connect to the root site in the site collection and store the object in $root
$root = $site.rootweb
# Store the Shared Documents document library in a variable $Docs
$docs = $root.lists["Shared Documents"]
# Display all the documents, their titles, names and IDs
$docs.items | format-table -property title,name,id
# Updates the title for each item in the list with Name
$docs.items | ForEach { $_["Title"] = $_["Name"]; $_.Update() }
# Display all the documents, their titles, names and IDs
$docs.items | format-table -property title,name,id
# Load SharePoint library
[system.reflection.assembly]::LoadWithPartialName("Microsoft.Sharepoint")
# Connect to the site collection http://SP2010Server:1212 and store the object in the $site variable
$site = New-Object Microsoft.SharePoint.SPSite("http://SP2010Server:1212")
# Connect to the root site in the site collection and store the object in $root
$root = $site.rootweb
# Store the Shared Documents document library in a variable $Docs
$docs = $root.lists["Shared Documents"]
# Display all the documents, their titles, names and IDs
$docs.items | format-table -property title,name,id
# Updates the title for each item in the list with Name
$docs.items | ForEach { $_["Title"] = $_["Name"]; $_.Update() }
# Display all the documents, their titles, names and IDs
$docs.items | format-table -property title,name,id
Comments
Post a Comment