2013年3月7日木曜日
【SharePoint2010】PowerShellでアイテムの作成者、更新者、作成日、更新日を変更する方法
# 作成者、更新者を変更
function ChangeCreatedUpdated([String] $sitePath, [String] $listName)
{
$sitePath = $sitePath.Split(" ")[0]
#Get web and document library objects
$web = Get-SPWeb $sitePath
$CustomList = $web.Lists[$listName]
$SPListItemCollection = $CustomList.Items
write-host "Update" $_.Name "to" $CustomList.Title "in" $web.Title "..."
foreach ($ListItem in $SPListItemCollection) {
$ListItem["Created"] = (Get-Date).AddDays(1)
$ListItem["Modified"] = (Get-Date).AddDays(2)
$SPFieldUserValue = New-Object Microsoft.SharePoint.SPFieldUserValue($web,<ユーザーID>,<#付きのユーザー名>)
$ListItem["Author"] = $SPFieldUserValue
$ListItem["Editor"] = $SPFieldUserValue
$ListItem.SystemUpdate($false)
}
$web.Dispose()
}
登録:
コメントの投稿 (Atom)
0 件のコメント:
コメントを投稿