Weboldal keresés

SharePoint hivatkozáslista létrehozása a PowerShell segítségével


Követelmény: Hozzon létre hivatkozáslistát a SharePointban a PowerShell segítségével

Íme a PowerShell-szkript hivatkozáslista létrehozásához a SharePointban:


Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

Function Create-LinkList($WebURL, $ListName, $ListDescription)
{
    try
    {
        $ErrorActionPreference ="Stop" 

        #Get the Web
        $Web = Get-SPWeb $WebURL

        #Get link list template
        $LinkListTemplate = [Microsoft.SharePoint.SPListTemplateType]::Links
        
        #Create link list
        $web.Lists.Add($ListName,$ListDescription,$LinkListTemplate)

        write-host "New List has been created!" -foregroundcolor Green
    }
    catch [System.SystemException]
    {
        write-host "List Creation failed due to:" $_.Exception.Message -foregroundcolor Red
    }
    finally
    {
        #Dispose web object
        $web.Dispose()
        $ErrorActionPreference ="Continue" 
    }
}

#Call the function to create a Link list
Create-LinkList "https://sharepoint.creswcent.com/" "Quick Links" "List of frequently accessed sites"

Tekintse meg az összes listasablontípust a Microsoft dokumentációjában: https://docs.microsoft.com/en-us/dotnet/api/microsoft.sharepoint.splisttemplatetype?view=sharepoint-server

Kapcsolódó cikkek