This is part 9 of 10 where we will be creating a new view for a list in SharePoint Online with PowerShell. This is part of the following series:

We will be collecting all available web templates in part 1 so we can use this to create a new site in part 2. In part 3 we will be creating a web for the newly created site. We then want to create a couple of site columns in part 4 which we will combine to a content type in part 5. This content type will be added (part 8) to our newly created document library in part 7 using a list template from part 6. After everything is set we will be setting the view in part 9 for this list to show the added columns we got from adding the content type. We only want to set permissions for myself so I’ll will be breaking the inheritance and setting permissions in part 10.

 Create new view for a list in SharePoint Online

This script will first create a new view and will add specified columns to this view. You can create an array using a .CSV file but I know the column names so I will create my array in the script.

This script will update the library to enable multiple content types and then add the newly created content type. We will first start by opening the SharePoint Online Management Shell as administrator which can be downloaded at


You will need to change the first variables to match your Office 365 tenant and copy this bit to PowerShell.

function new-SPOnlineView {
 #variables that needs to be set before starting the script
 $siteURL = ""
 $adminUrl = ""
 $userName = ""
 $listName = "finance"
 $viewName = "Blog View"
 $viewColumns = "Name", "Blog Text", "Blog Number", "Blog User", "Created", "Modified"
 # Let the user fill in their password in the PowerShell window
 $password = Read-Host "Please enter the password for $($userName)" -AsSecureString
 # set credentials
 $SPOCredentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($userName, $password)
 # Creating client context object
 $context = New-Object Microsoft.SharePoint.Client.ClientContext($siteURL)
 $context.credentials = $SPOCredentials
 $web = $context.web
 $list = $web.lists.GetByTitle($listName)
 #Creating new view using ViewCreationInformation (VCI)
 $vci = New-Object Microsoft.SharePoint.Client.ViewCreationInformation 
 $vci.Title = $viewName
 $vci.ViewTypeKind= [Microsoft.SharePoint.Client.ViewType]::None
#adding view to list
$listViews = $list.views
$addListView = $listViews.Add($vci)

#send the request containing all operations to the server
write-host "info: View created succesfully" -foregroundcolor green
write-host "info: $($_.Exception.Message)" -foregroundcolor red


You will be asked to enter the password and press enter


Verify if the view has been created for the list / library



You can find more properties for the ViewCreationInformation class at

The columns are case-sensitive so make sure you type these correctly, otherwise you will see an error “column does not exist”

One Comment

  • Thanks for the script. It helped to created the view quickly.
    And I am looking for the “Group By” setting in created view, Can anyone help on it.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.