Hiding Folders in a Document Library View Using Powershell

Ben SteginkUncategorizedLeave a Comment

I’ve been doing a lot of work with Powershell and SharePoint lately.  One of the things I’ve been doing is building out several list/document library views with Powershell.  In some of those views, the client has wanted to just see all of the files in a flat file structure (rather than having to drill through the folders).  I actually struggled for a little while trying to find the solution in Powershell.  After some digging and trial and error I discovered the solution.$web = Get-SPWeb “http://intranet.sharepoint.com”$doclib = $web.Lists[“Shared Documents”]$view = $doclib.Views[“All Documents”]$view.Scope = [Microsoft.Sharepoint.SPViewScope]::Recursive$view.Update()In this case, the name of the document library was Shared Documents and I had already created a view call All Documents.  After running this script, the All Documents shows all of the files in a flat file view for the document library.