PowerShell kullanarak bir Liste Öğesinin "Oluşturan" ve "Son Değiştirilen" Meta Veri Alanlarını Güncelleyin
Hiç SharePoint listesinin veya kitaplık öğesinin "Oluşturan" "Değiştiren" "Oluşturan" "Son Değiştirilen" gibi meta veri alanlarını güncellemek istediniz mi? Öğeler bir listeden diğerine programlı olarak kopyalanırken bu sütun değerlerinin güncellenmesi gerekir.
Bugün, SharePoint belge kitaplığında depolanan bir belgedeki meta veri alanlarını güncellemeye yönelik başka bir gereksinim daha vardı. PowerShell kullanarak bu metadata alanlarını “Oluşturan” “Değiştiren” “Oluşturan” “Son Değiştirilen” gibi güncelleyelim.
Güncelleme, SharePoint'te PowerShell kullanılarak alana göre oluşturuldu:
Aşağıdaki komut dosyası, bir SharePoint liste öğesindeki "Oluşturan" ifadesini değiştirir.
Add-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue
#Set Configuration Parameters
$WebURL = "https://portal.crescent.com/IQ/"
$ListName = "Questionnaire"
$ItemID = "147"
$UserName = "Crescent\Hamid"
#Get the Web, List, Item and User objects
$Web= Get-SPWeb $WebURL
$List= $web.Lists[$ListName]
$Item = $List.GetItembyID($ItemID)
$Author =$web.EnsureUser($UserName)
#update the created by & modified by columns
$Item["Author"] = $Author
$Item["Editor"] = $Author
$Item.SystemUpdate()
SharePoint'teki Meta Veri Alanlarını Güncellemek için PowerShell Komut Dosyası:
PowerShell ile SharePoint'teki bir dosyanın Oluşturan, Değiştiren, Oluşturan ve Değiştirilen alan değerlerinin nasıl güncelleneceği aşağıda açıklanmıştır.
Add-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue
#Define the Parameters
$WebURL = "https://sharepoint.crescent.com/projects/1033/"
$LibraryName = "Project Documents"
$DocumentName = "Project Schedules.xlsx"
$UserName = "Global\EricCo"
$DateValue = "2013-01-01 10:05" # Should be in "yyyy-mm-dd HH:mm" format
#Get the Web
$web= Get-SPWeb $WebURL
#Get the Library
$list= $web.Lists[$LibraryName]
#Get the User
$Author =$web.EnsureUser($UserName)
#Get the document
$Document = $list.Items | where {$_.Name -eq $DocumentName}
#update created by column sharepoint programmatically
$Document["Author"] = $Author
#set modified by programmatically
$Document["Editor"] = $Author
#Set Created Date value
$Document["Created"] = $DateValue
#sharepoint powershell to update modified date
$Document["Modified"] = $DateValue
$Document.UpdateOverwriteVersion() #Can use $Document.SystemUpdate() as well..
SharePoint Online'da Oluşturan, Oluşturan, Değiştiren, Değiştirilen alan değerlerini güncellemek için, bkz.: SharePoint Online: PowerShell kullanarak Oluşturan/Değiştiren, Oluşturan/Değiştiren Alan Değerlerini Güncelleme
