- ### Load SharePoint SnapIn
- if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null)
- {
- Add-PSSnapin Microsoft.SharePoint.PowerShell
- }
- ### Load SharePoint Object Model
- [System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.SharePoint”)
- ### Get web and list
- $web = Get-SPWeb http://myweb
- $list = $web.Lists["List with Document Sets"]
- ### Get Document Set Content Type from list
- $cType = $list.ContentTypes["Document Set Content Type Name"]
- ### Create Document Set Properties Hashtable
- [Hashtable]$docsetProperties = @{"DocumentSetDescription"="A Document Set"}
- $docsetProperties = @{"CustomColumn1"="Value 1"}
- $docsetProperties = @{"CustomColum2"="Value2"}
- ### Add all your Columns for your Document Set
- ### Create new Document Set
- $newDocumentSet = [Microsoft.Office.DocumentManagement.DocumentSets.DocumentSet]::Create($list.RootFolder,"Document Set Title",$cType.Id,$docsetProperties)
- $web.Dispose()
Als weite Methoden unter [Microsoft.Office.DocumentManagement.DocumentSets.DocumentSet] steht noch folgendes zur Verfügung:
| Document Set Methoden |
Mehr Details zu den Methoden findet man auch in der MSDN hier . Mit diesem Handwerkszeug sollte nichts mehr zwischen der PowerShell und Dokumentenmappen stehen!
Good Luck,
Andreas

2 Kommentare:
nice post!
Thanks, your post is really helpful but I got an error message while I'm creating a document sets in line 23 of your code.
The command is shown below.
$newDocumentSet = [Microsoft.Office.DocumentManagement.DocumentSets.Docu
mentSet]::Create($list.RootFolder,$docsetName,$cType.Id,$docsetProperties)
The error code is shown below.
Exception calling "Create" with "4" argument(s): "0x80070005"
At line:1 char:89
+ $newDocumentSet = [Microsoft.Office.DocumentManagement.DocumentSets.DocumentS
et]::Create <<<< ($list.RootFolder,$docsetName,$cTypeSharedPractice.Id,$docsetP
roperties)
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
Do you have any suggestion? Thank you in advance.
Kommentar veröffentlichen