PowerShell : Hide SharePoint List via PnP / o365 CLI cmdlet


The creation of a SharePoint list may occasionally be necessary when developing internal business procedures for organisations. For the end user, who sees the list there, it might occasionally cause confusion. Therefore, we may prevent this by removing the list from the SharePoint site. The list will function normally and have a URL for access. When using List Formatting to create a new list while delaying its availability, this situation can also be employed. A few steps in SharePoint may be used to accomplish this. The Office 365 CLI and PNP PowerShell will be used as examples.

Office 365 CLI Cmdlet

##initialize needed variables
$toHideListName = "MyListName"
$site = "https://mysharepointtenant.sharepoint.com/"

##Connect to your site via o365 cmdlet login
$lists = o365 spo list get --webUrl $site -t $toHideListName -o json| ConvertFrom-Json
o365 spo list set --webUrl $site -i $list.Id -t $toHideListName --hidden true 

PnP PowerShell Cmdlet

##initialize needed variables
$toHideListName = "MyListName"
$site = "https://mysharepointtenant.sharepoint.com/"

##Connect to your SharePoint site with PnP cmdlet
Connect-PnPOnline -Url $site -UseWebLogin
Set-PnPList -Identity $toHideListName -Hidden $true

Simply set the value of hidden to false if you want the list to return to being Visible. If you use Power Automate app, these hidden lists won’t show up in the dropdown; however, if you use a custom property and add the name there, it will work.

Now that’s another tip! Hope it helps somehow. Let me know if you have questions or just leave a comment if we missed something.

Happy SharePointing! #SharingIsCaring

Automation Check Current User Is External User CLI Content Type CopyExcelRecordToList DenyAddAndCustomizePages Design ExcelPowerAutomate Expand Flows Issues Javascript Limitation Limitations List Templates Metadata ModernScriptEditor Node NodeJs Node Versioning NVM O365 o365 Cli OneDrive People People Metadata Permission PnP Power Automate PowerShell Rest Endpoint Save as Template ScriptEditor Send an HTTP Request to SharePoint SharePoint SharePoint Architecture SharePoint Designs SharePointList SharePoint Modern SharePoint Online SPFX SPO Sync Versioning Workflows

Leave a Comment

Your email address will not be published. Required fields are marked *