Enable tree view in current navigation within SharePoint

Sometime we need to enable tree view in current navigation to help navigate within document libraries.

Traditional Way:

Site Settings -> Look and Feel: Navigation Elements -> Check ‘Enable Tree View’

Programmatic way using PnP Powershell:

try {
    $web = Get-PnPWeb -Includes TreeViewEnabled
    Write-Host "Setting options to enable tree view..."
    $web.TreeViewEnabled = $true        
    $web.Update()
    Invoke-PnPQuery
    Write-Host "Completed."
}
catch {
    $ErrorMessage = $_.Exception.Message
    Write-Host "Error enabling tree view. $ErrorMessage"
}

Disable ‘Allow items from this site to be downloaded to offline clients’ in SharePoint

Sometime we need to disable the “Sync” button in SharePoint document libraries and that can be done by the following methods.

Traditional Way:

Site Settings -> Search: Search and offline availability -> Set ‘Allow items from this site to be downloaded to offline clients?’ to “No”

Programmatic way using PnP Powershell:

try {
    $web = Get-PnPWeb -Includes ExcludeFromOfflineClient
    Write-Host "Setting options to disable 'Allow items from this site to be downloaded to offline clients'..."
    $web.ExcludeFromOfflineClient = $true        
    $web.Update()
    Invoke-PnPQuery
    Write-Host "Completed."
}
catch {
    $ErrorMessage = $_.Exception.Message
    Write-Host "Error disabling offline clients. $ErrorMessage"
}