【发布时间】:2012-06-23 02:38:45
【问题描述】:
如何使用 PowerShell 修改 SharePoint 列表中的项目值?当我尝试以下操作时:
$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>"
}
}
上面写着unable to index into an object of type SPlistItem。
【问题讨论】:
-
哪一行报错?
-
函数Add(),它说异常调用Add with 3 arguments
-
你能帮帮我吗?我可以弄清楚几个小时!
-
试试
$SPFileCollection.Folders["EM_Doc_Library"].Add("$tmpValue",$upFile.OpenRead(),$false) -
是说后面缺少表达式,
标签: sharepoint powershell