![](/img/trans.png)
[英]How can I get the “Copy Link” from a document on SharePoint Online document library using Powershell
[英]Create a Document Library from a Template using SharePoint Online PowerShell
如何使用SharePoint Online PowerShell从保存为模板的现有文档库中创建新文档库?
我正在尝试以下方法:
New-PnPList -Title "Test" -Template DocLibTemplate.stp -Url Test
我在CSOM PowerShell上没有运气... PnP似乎是最好的选择。
以下PowerShell供您参考。
$ListTemplateInternalName="DocLibTemplate.stp"
$ListName ="PnpDocument"
Connect-PnPOnline -Url https://xx.sharepoint.com/sites/lz -Credential (Get-credential)
$Context = Get-PnPContext
$Web = $Context.Site.RootWeb
$ListTemplates = $Context.Site.GetCustomListTemplates($Web)
$Context.Load($Web)
$Context.Load($ListTemplates)
Invoke-PnPQuery
$ListTemplate = $ListTemplates | where { $_.InternalName -eq $ListTemplateInternalName }
if ($ListTemplate -eq $null)
{
Throw [System.Exception] "Template not found"
}
$ListCreation = New-Object Microsoft.SharePoint.Client.ListCreationInformation
$ListCreation.Title = $ListName
$ListCreation.ListTemplate = $ListTemplate
$Web.Lists.Add($ListCreation)
Invoke-PnPQuery
Disconnect-PnPOnline
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.