Forum Discussion

hjdrent's avatar
hjdrent
Copper Contributor
Jan 18, 2021

How can I change the View of a SharePoint Online folder programmatically?

Hi

I have a powershell script that creates Folders in SharePoint online. 

I'm using Add-PnPFolder to do so. 

By default the new folder view is sorted by Name. I wish to change the default view so that it is sorted by the field Created. 

Manually this can easily be done. But programmatically I have no clue how to change the view of a PnPFolder.

Here's the part of the code where I create the folder...

 

Connect-PnPOnline -ClientId $SPO_AppId -ClientSecret $SPO_AppSecret -Url $siteUrl

$connection = Get-PnPConnection

if ($connection) {

Add-PnPFolder -Folder /Team/Acquisition -Name Approvals -Connection $connection

}

 

Get-PnPView only works on PnPLists, not on PnPFolders unfortunately.

No RepliesBe the first to reply

Resources