如何使用 PowerShell 修改 SharePoint 列表中项目的值 [英] How to modify an item's value in a SharePoint list with PowerShell

查看:47
本文介绍了如何使用 PowerShell 修改 SharePoint 列表中项目的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用 PowerShell 修改 SharePoint 列表中项目的值?当我尝试以下操作时:

How do I use PowerShell to modify an item's value in a SharePoint list? When I try the following:

$splist.GetItems() | ForEach-Object{
 #Write-Host $_["Item"]

 if($_["Item"] -eq $null){
  $SPFileCollection = $folder.Files
  $upFile=Get-ChildItem D:\Tools\SP-scripts\MDNSO-template.aspx
  $tmpValue = $_["Title"]
  $filename = "EM_Doc_Library\$tmpValue"
  $SPFileCollection.Add("EM_Doc_Library\$tmpValue",$upFile.OpenRead(),$false)
  Write-Host "creating the file"
  Write-Host $_["Title"]
  $_["Item"] = "MDNSO-<$tmpValue>"
 }
}

它说,无法索引到 SPlistItem 类型的对象.

推荐答案

以下是您可以尝试执行的操作的摘要:

Here is a summary of what you could try to do:

$spWeb = Get-SPWeb -Identity http://yourdomain/sites/config
$spList = $spWeb.Lists["AppSettings"]
$spItem = $spList.GetItemById(10013) //or another way that you prefer.
$spItem["Name"] = "MyName"
$spItem.Update()

有关更多信息,您应该查看这篇博文.它包含如何使用 PowerShell 添加、更新和删除列表项的示例:http://mysharepointwork.blogspot.no/2010/09/addupdatedelete-list-items-using.html

For more info you should check out this blog post. It contains examples of how to add, update and delete list items with PowerShell: http://mysharepointwork.blogspot.no/2010/09/addupdatedelete-list-items-using.html

这篇关于如何使用 PowerShell 修改 SharePoint 列表中项目的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆