I have a documents library named “Shared Documents” in which I want to set “Show all items without folders” property for “All Documents” list view.
You can download setup files from the releases section of the PnP PowerShell repository.
Copy the below script and paste it in a notepad. Save the file as SetListView.ps1.
- # Input Parameters
- $siteURL="https://c986.sharepoint.com/sites/dev"
- $listName="Shared Documents"
- $viewName="All Documents"
-
- # Connect to SharePoint Online site
- Connect-PnPOnline –Url $siteURL –Credentials (Get-Credential)
-
- # ViewScope Enum
- $viewScope=[Microsoft.SharePoint.Client.ViewScope]::Recursive
-
- # Update the list view
- Set-PnPView -List $listName -Identity $viewName -Values @{Scope=$viewScope}
ViewScope enum:
Open PowerShell window and run the following command.
folderlocation – SetListView.ps1 file location
Run the following command
Reference: Set-PnPView
Thus in this blog, you saw how to set the list view scope in SharePoint Online using PnP PowerShell.