kwizcom banner advertisement

Create SharePoint Link List using PowerShell

PowerShell script to create Link list in SharePoint:
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 Link lisst
 Create-LinkList "http://sharepoint.creswcent.com/" "Quick Links" "List of frequently accessed sites" 
Create SharePoint Link List using PowerShell Create SharePoint Link List using PowerShell Reviewed by Salaudeen Rajack on April 14, 2014 Rating: 5

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.