Tuesday, November 8, 2016

SharePoint Online: How to Hide a List or Library using PowerShell

Requirement: Hide a list or library from SharePoint Online site.

SharePoint Online: Hide Document Library using PowerShell
There are many ways to hide a SharePoint online list. Here is the PowerShell CSOM script to create hidden lists in SharePoint online.  

#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
  
#Config Parameters
$SiteURL= "https://crescent.sharepoint.com/sites/sales/"
$LibraryName="ProjectConfig"

#Setup Credentials to connect
$Cred = Get-Credential
$Cred = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.UserName,$Cred.Password)

Try {
    #Setup the context
    $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
    $Ctx.Credentials = $Cred
  
    #Get the web and Library
    $Web=$Ctx.Web
    $List=$web.Lists.GetByTitle($LibraryName)

    #Hide the list
    $List.Hidden = $True
    $List.Update()
    $Ctx.ExecuteQuery()
     
    Write-host -f Green "List hidden Successfully!"
}
Catch {
    write-host -f Red "Error hiding List: " $_.Exception.Message
}
You can also use SharePoint designer to mark a list hidden from browser. Read more here: How to hide a list in SharePoint?
how to hide list in sharepoint online

Tags: sharepoint online hidden list, sharepoint online hide task list, sharepoint online create hidden list, sharepoint online hide document library, sharepoint online hide library



You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Check out these SharePoint products:

No comments :

Post a Comment

Please Login and comment to get your questions answered!


You might also like:

Related Posts Plugin for WordPress, Blogger...