Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

This code works fine.

$spWeb = Get-SPWeb -Identity http://xxx
 $listTemplate = [Microsoft.SharePoint.SPListTemplateType]::GenericList 
 $spListCollection = $spWeb.Lists 
 $spListCollection.Add("ExternalSites","External Sites",$listTemplate)
 $spList = $spWeb.GetList("/Lists/ExternalSites")
 $spFieldType = [Microsoft.SharePoint.SPFieldType]::Text 
 $spList.Fields.Add("ExtSiteUrl",$spFieldType,$false)
 $spList.Fields.Add("ExtSiteDescription",$spFieldType,$false)
 $spList.Update()

However the Add method receives the display name, if I change those to. External Site Url and External Site Description

Then the internal names dont match anymore. They are something like:

External_x0020_Site_x0020_Url External_x0020_Site_x0020_Descri

I want to be able to change at least the displayname via powershell but leave the internal name as: ExtSiteUrl and ExtSiteDescription

share|improve this question

1 Answer 1

up vote 1 down vote accepted

By default, the title of the field would be the display name of the field and the internal name will not be changed since it will be used for programmatic purposes. Change the title property and you will be able to change the display name.

You can try changing this - $spList.Fields["External Site Desc"].Title

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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