I have a custom List called 'IssuesList' with 4 fields - "IssueTitle","IssueID","IssueDesc","Status"

While displaying display form I should show 3 fields expect Issue ID i.e. IssueID should be hidden.

and on edit form only Status field should be editable. So using SharePoint designer I created respective Edit form and display forms and changed XSLT to control the display mode on the fields.

I have everything scripted in powershell till now - creation of custom list, publishing pages, webparts etc. however I am looking for how to provision or associate these 2 list forms with IssuesList after I create the list in new site.

I have restrictions on using wsp and site/list template due to business needs. So I need to know if there is any way I can upload these 2 files after I create custom list in powershell and associate them as defaultdisplay and defauteditforms?

Please advise

1 Answer 1


Here is one script which I use often

$url = "Enter URL" 

$listname = Read-Host "Enter List Name"
$web = get-spweb $url 
$list = $web.lists[$listname]

#delete existing forms

$files = $list.rootfolder.files
$form1 = $list.RootFolder.files | ?{$_.url -match "dispform.aspx"}
$form2 = $list.RootFolder.files | ?{$_.url -match "editform.aspx"}
$form3 = $list.RootFolder.files | ?{$_.url -match "newform.aspx"}

#Upload new forms
#$dispform = $files.add($dispformurl, [Microsoft.SharePoint.SPTemplateFileType]::FormPage)
#$editform = $files.add($editformurl, [Microsoft.SharePoint.SPTemplateFileType]::FormPage)
#$newform = $files.add($newformurl, [Microsoft.SharePoint.SPTemplateFileType]::FormPage)

#Set new form urls
#$editformurl = $list.RootFolder.ServerRelativeUrl + "/editform.aspx"
#$dispformurl = $list.RootFolder.ServerRelativeUrl + "/Dispform.aspx"
#$newformurl = $list.RootFolder.ServerRelativeUrl + "/NewForm.aspx"

#set new form association
$list.DefaultDisplayFormUrl = $dispformurl
$list.DefaultEditFormUrl = $editformurl 
$list.DefaultNewFormUrl = $newformurl



  • Hi Amal, I have seen this script and I believe this one re-creates the forms from existing ones. My requirement is to upload new ones which are created using SharePoint designer.
    – user12345
    Nov 27, 2014 at 14:02
  • Yes you can upload the forms using Files.Add method.. There are plenty of script available. Once you have uploaded you can set the URL as in the script. Nov 27, 2014 at 14:05
  • Thanks Amal, Can you please provide a script which can do this add? Whatever scripts I looked at need to specify [Microsoft.SharePoint.SPTemplateFileType]::FormPage but in powershell I am not sure how to upload file Files.Add and then assign this templatefiletype as form page. Appreciate your help
    – user12345
    Nov 27, 2014 at 16:11
  • Check this In your case you dont need to loop. Nov 27, 2014 at 16:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.