![](/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.