SharePoint Online: Get Default List Form (New/Edit/Display) URLs using PowerShell

Requirement: Get the default list form URLs in SharePoint Online.

How to Get the List Form URLs in a SharePoint Online List?

  • Just open the SharePoint Online site in SharePoint Designer,
  • Navigate to the Lists >> Open the Target List >> and You’ll find the default list of forms under the “Forms” section.sharepoint online modern list new item form url

CSOM PowerShell script to get SharePoint Online List form URLs

Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameChecking
 
#Set Parameters
$SiteURL= "https://Crescent.sharepoint.com/sites/marketing"
$ListName="Announcements"

#Setup Credentials to connect
$Cred = Get-Credential
     
#Setup the context
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.UserName,$Cred.Password)
 
#Get the List
$List = $Ctx.Web.Lists.GetByTitle($ListName)
     
#Get List Properties
[string[]]$Properties = @("DefaultNewFormUrl","DefaultDisplayFormUrl","DefaultEditFormUrl")
$List.Retrieve($Properties)
$Ctx.Load($List)
$Ctx.ExecuteQuery()    

#Get sharepoint online list form urls
$List.DefaultNewFormUrl
$List.DefaultEditFormUrl
$List.DefaultDisplayFormUrl

PnP PowerShell Script to Get List Forms in SharePoint Online

PnP PowerShell makes things even simpler!

#Set Parameters
$SiteURL= "https://crescent.sharepoint.com/sites/marketing"
$ListName="Announcements"

#Connect to PnP
Connect-PnPOnline -Url $SiteURL -UseWebLogin

#Get List Form URLs
$List = Get-PnPList -Identity $ListName -Includes DefaultDisplayFormUrl, DefaultEditFormUrl, DefaultNewFormUrl
$List.DefaultDisplayFormUrl
$List.DefaultEditFormUrl
$List.DefaultNewFormUrl

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