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.
The order of the items displayed in view is configured in the view property, not in item property.
Code example to change the sorting property of a view: