用powershell 更新一个list item
$web = Get-SPWeb "http://spsapp/mti-blog"
$list = $web.Lists["Posts"]
$posts = $list.Items
foreach ($post in $posts)
{ $createdby4 = $post["createdby4"] #createdby4 is my list column
if (($createdby4 -ne $Null) -and ($createdby4.Contains("i:0.w|soe")))
{
$createdby4 = $createdby4.SubString($createdby4.IndexOf("\") + 1)
$post["createdby4"] = $createdby4
$post.Update()
}
}
$web.Dispose()
请注意脚本中的判断条件等都是基于我当前的业务需求来的,不要被confused了。 另外,要使用这个脚本,可以新建一个后缀为ps1的文件,保存,运行sharepoint powershell,set-location到你保存ps1的文件的路径, 如set-location c:\myps1, 然后可以get-childitem,来显示当前路径的文件,然后以如下格式执行你的脚本:.\yourps1filename.ps1
Life is so beautiful

浙公网安备 33010602011771号