In this article I am going to explain how we can deploy Custom List Forms using PowerShell, this is mainly useful to deploy custom pages in multiple environments instead of recreating list.
Steps to Deploy Custom Forms:
- Create test list in your site.

- Create custom List form using SharePoint Designer and make that as default one for creating new item.


- We can see the new custom form to create new item to the list.

- After deploying this list to different/same site, there is a change in requirement to add new column.
This change can be deployed by creating new list in the target server but it is going to affect the data which is already created.
The second option is to deploy only the list form using PowerShell.
- Export the updated custom form to local drive and deploy using PowerShell script.

- Open Windows PowerShell management studio or PowerShell ISE and execute the following PowerShell script to deploy files.

- PowerShell Script code:
- [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
- [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Publishing")
- [System.Reflection.Assembly]::LoadWithPartialName("System")
- [System.Reflection.Assembly]::LoadWithPartialName("System.IO")
- $siteUrl = "http://RKSite/"
- $listName = "RK_List"
- $templateFilesFolderPath = "C:\RK\Custom list forms\Forms"
- $web = Get-SPWeb -Identity $siteUrl
- if($web)
- {
- try
- {
- $list = $web.Lists.TryGetList($listName)
- $files = Get-ChildItem -Path $templateFilesFolderPath -Force -Recurse
- foreach ($file in $files)
- {
- $stream = $file.OpenRead()
- $completedFileName = $list.RootFolder.Files.Add($file.Name, $stream, [Microsoft.SharePoint.SPTemplateFileType]::FormPage)
- $stream.Close()
- Write-Host $completedFileName.Name "Uploaded into the list"
- }
- $list.Update();
- }
- catch
- {
- Write-Host $($_.Exception.Message)
- }
- }
- else
- {
- Write-Host "Site not exist"
- }
- Write-Host "--- Script Completed ---"
- PowerShell Configuration:
Site Url = <<Site url to deploy the form>>
List Name = <<List name to deploy the from>>
templateFilesFolderPath = <<Local folder path for list forms>>
- Execute the script using the following command:
.\DeployCustomListForm.ps1

- You can see the updated custom list form in target list.


Important Note: If we are going to update this form in different server we need to update the target list id in the custom form.
We need to replace all list ids in the custom form otherwise it will throw an error, better select replace all option


web studentPosted Jun 8, 2017, 3:35 AM
Hi RB. Thanks for the nice article. Do you happen to know of a PowerShell Script to download a SharePoint List Form's source code? I've tried a few scripts from the internet, but they do not give me the whole file (as in SPD Advanced Editing Mode). Any hint is greatly appreciated.
Ramakrishna BasagallaPosted Nov 28, 2015, 9:57 AM
Thanks for posting your feedback.
Rupali ShindePosted Nov 27, 2015, 5:51 AM
nice article on powershell ..
Ramakrishna BasagallaPosted Oct 12, 2015, 1:09 PM
Thanks for feedback :-)
Shakti SaxenaPosted Oct 2, 2015, 7:41 AM
good one
Karthikeyan KPosted Oct 2, 2015, 2:21 AM
Good one sir...Thanks for sharing
Santhakumar MunuswamyPosted Oct 1, 2015, 3:50 PM
Good one
Priyaranjan K SPosted Oct 1, 2015, 2:06 PM
Good One ...
Abhay ShankerPosted Oct 1, 2015, 6:16 AM
Nice one...
Ankit BansalPosted Oct 1, 2015, 5:08 AM
nice..thanks for sharing..
Nilesh JadavPosted Oct 1, 2015, 4:24 AM
Great !!