【发布时间】:2012-07-03 06:07:42
【问题描述】:
这是我的文档库的样子。我的文档库有 2 种内容类型。一种内容类型基于文档,另一种内容类型基于“链接到文档”类型。
我正在尝试使用 powershell 脚本上传一些文件。我正在使用 csv 文件逐行读取并将文件上传到文档库。我在 $i.fileNameASPX 上遇到错误。 Powershell 告诉我 , 之后缺少表达式。那么该怎么办。
if($i.ContentType = "LegalLink2Document")
{
$itemType = $docLibrary.ContentTypes[$i.ContentType]
$newFile = $docLibrary.RootFolder.Files.Add($i.fileNameASPX, UTF8Encoding.UTF8.GetBytes(builder.ToString()), $true)
$theItem = $newFile.Item
$theItem["ContentTypeId"] = $itemType.Id
$itemUrl = ew-object Microsoft.SharePoint.SPFieldUrlValue()
$itemUrl.Url = $i.fileLinkUrl
$itemUrl.Descrition = $i.URLDESC
$theItem["URL"] = $itemUrl
}
【问题讨论】:
-
你的 $itemUrl 是错字吗?假设是New-Object吧??
-
哦,是的。那也是。但它卡在 $newfile 从顶部的第 4 行。我认为 UTF8Enconding 应该是不同的格式。
-
这似乎是一个重复的帖子:stackoverflow.com/questions/11304002/…我回复了另一个帖子
标签: powershell sharepoint-2010 document-library