SharePoint Online: Set Default View using PowerShell

Requirement: Change default view in SharePoint Online.

How to Change Default View in SharePoint Online?

To set a custom list view as default view in SharePoint Online,

  • Go to List Settings >> Scroll down to the bottom and click on the view name you wish to set as default view under the “Views” section
  • In the Edit view page, check the box next to “Make this the default view” and click OK to save your changes.
    change default view in sharepoint online

So next time, when you hit:, you’ll be taken into the default view “Active Projects” at:

Tips: In Modern Experience, We can use “Set Current View as Default” in Views Drop-down!

SharePoint Online: Set Default View using PowerShell

Here is the PowerShell script to change default view in SharePoint Online.

#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"

Function Set-SPODefaultView()
        [Parameter(Mandatory=$true)] [string] $SiteURL,
        [Parameter(Mandatory=$true)] [string] $ListName,
        [Parameter(Mandatory=$true)] [string] $ViewName
    Try {
        #Setup Credentials to connect
        $Cred= Get-Credential
        $Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)
        #Setup the context
        $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
        $Ctx.Credentials = $Credentials
        #Get the List
        $List = $Ctx.Web.Lists.GetByTitle($ListName)
        #Get the list view by title

        #Set the view as default view
        Write-host -f Green "List View '$ViewName' is Set as the Default View!" 
    Catch {
        write-host -f Red "Error Setting Default View!" $_.Exception.Message

#Set Parameters
$ViewName="Active Projects"

#Call the function 
Set-SPODefaultView -SiteURL $SiteURL -ListName $ListName -ViewName $ViewName

We also have MobileView, MobileDefaultView properties to enable mobile view and make a default view for mobile!

PnP PowerShell to Set a List View as Default View:

#Config Variables
$SiteURL = ""
$ListName= "Projects"
$ViewName= "Active Projects"

#Get Credentials to connect
$Cred = Get-Credential

Try {
    #Connect to PnP Online
    Connect-PnPOnline -Url $SiteURL -Credentials $Cred

    #Get the Context
    $Context = Get-PnPContext

    #Get the List View from the list
    $ListView  =  Get-PnPView -List $ListName -Identity $ViewName -ErrorAction Stop

    #Set View as Default View
    $ListView.DefaultView = $True
    Write-host -f Green "View '$ViewName' Set as Default View of the List!"
catch {
    write-host "Error: $($_.Exception.Message)" -foregroundcolor Red

You can also use: Set-PnPView to set a view as default:

Connect-PnPOnline -Url $SiteURL -Credentials $Cred

#Set the List View as Default view
Set-PnPView -List $ListName -Identity $ViewName -Values @{DefaultView=$True}

With Set-PnPView cmdlet, you can update properties of a list view such as: Title, Hidden, JSLink, RowLimit, ViewQuery, Etc.

Salaudeen Rajack

Salaudeen Rajack is a SharePoint Architect with Two decades of SharePoint Experience. He loves sharing his knowledge and experiences with the SharePoint community, through his real-world articles!

Leave a Reply