我需要为此SharePoint 2010列表中的每个名称创建一个文档集。文档集标题是人员的名字和姓氏,文档集具有委员会名称属性,也需要设置。委员会名称来自同一个SharePoint列表。
我不明白我的代码有错误:
$ErrorActionPreference = "Stop"
$url = "http://SERVER/etest"
$listName = "Advisory Committee"
$doclib = "TACM Application Docments"
$web = Get-SPWeb $url;
$list = $web.Lists[$listName];
$item = $list.Items;
$item | ForEach-Object {
$fullName = $_['Last Name'] + ", " + $_['First Name']
$committeeName = $_['Committee Name']
$cType = $list.ContentTypes["Document Set"]
[Hashtable]$docsetProperties = @{"Committee Name"=$committeeName}
$newDocumentSet = [Microsoft.Office.DocumentManagement.DocumentSets.DocumentSet]::Create($doclib.RootFolder,
$fullName,$cType.Id, $docsetProperties)
}
$web.Dispose()
我收到以下错误: ForEach-Object:找不到“Create”的重载和参数count:“4”。 在C:\ Users \ ev \ desktop \ docset.ps1:10 char:23 + $ item | ForEach-Object<<<< { + CategoryInfo:NotSpecified:(:) [ForEach-Object],MethodException + FullyQualifiedErrorId:MethodCountCouldNotFindBest,Microsoft.PowerShell .Commands.ForEachObjectCommand
答案 0 :(得分:0)
DocumentSet.Create method期望第一个参数是文件夹(SPFolder类型):
parentFolder Type: Microsoft.SharePoint.SPFolder The folder in which to create the new DocumentSet object.
在你的情况下,你传递了一个无效的对象$doclib.RootFolder
,因为$doclib
是string
变量,可能你想要这样的东西:
$doclibName = "TACM Application Docments"
$doclib = $web.Lists[$doclibName];
$newDocumentSet = [Microsoft.Office.DocumentManagement.DocumentSets.DocumentSet]::Create($doclib.RootFolder,$fullName,$cType.Id, $docsetProperties)
示例强>
$url = "http://contoso.intranet.com"
$listTitle = "Documents"
$web = Get-SPWeb $url;
$list = $web.Lists[$listTitle]
$docSetContentType = $list.ContentTypes["Document Set"]
[Hashtable]$docSetProperties = @{}
$docSetName = "Archive"
$docSet = [Microsoft.Office.DocumentManagement.DocumentSets.DocumentSet]::Create($list.RootFolder,$docSetName,$docSetContentType.Id, $docSetProperties)
$web.Dispose()
Library Settings
,然后点击Advanced Settings
Yes
并点击Ok
按钮Add from existing site content types
链接并选择
Document Set
内容类型,然后点击Ok
按钮