Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sharepoint 2013 要使用已具有文档库的power shell在SharePoint 2013中创建文档库吗_Sharepoint 2013 - Fatal编程技术网

Sharepoint 2013 要使用已具有文档库的power shell在SharePoint 2013中创建文档库吗

Sharepoint 2013 要使用已具有文档库的power shell在SharePoint 2013中创建文档库吗,sharepoint-2013,Sharepoint 2013,我有一个SharePoint网站集,用于: 以及本网站集中的图书馆 1.概述 2.秩序 我想创建一个名为“W_General”的新库,它的属性与“General”库相同(可以说只是重复的),但“W_General”应该为空(没有文档,只有文件夹) 请注意,这些库的大小非常大,所以模板不是一个好的选择。我希望所有这些都在powershell脚本中。如果未使用内容类型,则需要在新库上重新创建源库的字段,请提供帮助。在PowerShell中,使用SPFieldCollection的AddFieldAs

我有一个SharePoint网站集,用于:

以及本网站集中的图书馆

1.概述
2.秩序

我想创建一个名为“W_General”的新库,它的属性与“General”库相同(可以说只是重复的),但“W_General”应该为空(没有文档,只有文件夹)


请注意,这些库的大小非常大,所以模板不是一个好的选择。我希望所有这些都在powershell脚本中。如果未使用内容类型,则需要在新库上重新创建源库的字段,请提供帮助。在PowerShell中,使用SPFieldCollection的
AddFieldAsXml
方法,这非常简单,如下例所示:

if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) {
    Add-PSSnapin "Microsoft.SharePoint.PowerShell"
}
$web = get-spweb "http://bp1amsapt229:14146/gom/mdrcs"
$source = $web.lists["General"]
$newListId = $web.lists.add("W_General", $source.Description, $source.BaseTemplate)
$web.Update()
$list = $web.lists.GetList($newListId,$true)
$source.fields | ForEach-Object{
    if(-not $_.FromBaseType){
        write-host "adding $($_.Title)... " -NoNewline -ForegroundColor Yellow
        $dest.Fields.AddFieldAsXml($_.SchemaXml);
        $dest.Update();
    }else{
        write-host "skipped adding $($_.Title)" -ForegroundColor Gray
    }
}
$source.Views | ForEach-Object{
    write-host "adding view '$($_.Title)'... "
    $dest.Views.Add($_.Title, $_.ViewFields, $_.Query, $_.RowLimit, $_.Paged, $_.DefaultView)
    $dest.Update()
}
$web.Dispose()
请注意,如果需要,还需要将视图从源库添加到目标库


上述脚本不会复制附加到库的任何表单或工作流。

感谢您的出色解决方案。我使用的是内容类型,如果启用解析器,我可以使用您的解决方案。 解析器启用代码

如果($web.ParserEnabled-ne$true) {

$web.ParserEnabled=$true $web.Update()

}

有人能告诉我这是否会对我的记录库产生任何影响,因为它默认处于停用阶段。如果我在创建复制库后禁用它,它将回滚启用后激活的所有功能。它将对文档元数据产生什么影响。请解释一下