Sharepoint 是否有办法将标题列表字段全局更改回';标题';2007年

Sharepoint 是否有办法将标题列表字段全局更改回';标题';2007年,sharepoint,sharepoint-2007,Sharepoint,Sharepoint 2007,在每个SharePoint开发人员的生活中,迟早都会有人玩弄内容类型,并重命名项目基本类型中的标题字段。这有两个影响: 所有新列表都有新名称,而不是“标题” 网站集中的所有列表都已重命名其标题字段 现在,我已经将项目内容类型设置回了OK,但是如果不是数千个列表的话,也有数百个列表现在有一个名为“Publication Title”的字段,我想将其改回“Title” 在谷歌搜索之后,我很快就熟悉了powershell,并且正在准备一个脚本来遍历网站集并重命名所有标题字段 但我肯定我不是第一个这

在每个SharePoint开发人员的生活中,迟早都会有人玩弄内容类型,并重命名项目基本类型中的标题字段。这有两个影响:

  • 所有新列表都有新名称,而不是“标题”
  • 网站集中的所有列表都已重命名其标题字段
现在,我已经将项目内容类型设置回了OK,但是如果不是数千个列表的话,也有数百个列表现在有一个名为“Publication Title”的字段,我想将其改回“Title”

在谷歌搜索之后,我很快就熟悉了powershell,并且正在准备一个脚本来遍历网站集并重命名所有标题字段

但我肯定我不是第一个这样做的人,我肯定我不是第一个想到这个解决方案的人。有没有人在密码上撒了谎来解决这个问题


哦,是的,这是在生产农场。哈哈。

所以我想这是一个不

我编写了一个powershell脚本来进行重命名:

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") > $null

function global:Get-SPSite($url){
    return new-Object Microsoft.SharePoint.SPSite($url)
}

#Change these variables to your site URL and list name
$siteColletion = Get-SPSite("http://go.snap-undp.org/focusareas/")
$webs = $siteColletion.allwebs

#Walk through each site in the site collection
#use FOR loops because collections break when you update them
for($webIndex=0;$webIndex -ne $webs.count;$webIndex++){
    #use this for output
    $webTitle = $webs[$webIndex].title.toString()
    "PROCESSING $webTitle"

    #loop though each list in the current website
    for($i=0;$i -ne $webs[$webIndex].lists.count;$i++){

        #this is used for output and to make the code a little more readable
        $listTitle = $webs[$webIndex].lists[$i].toString()

        #loop through each field in the lsit, looking for the offending name
        foreach($field in $webs[$webIndex].lists[$i].fields){
            if($field.title -eq "Publication Title"){
                if($listTitle -eq "Participants" -or $listTitle -eq "User Account Request List"){
                    $field.title = "Last Name"
                    "workshop update to $listTitle"
                }else{
                    $field.title = "Title"
                    "normal update to $listTitle"
                }
                #$field.Update()
                break
            }
        }
    }
}
#Dispose of the site object
$siteColletion.Dispose()
这是相当具体的。它查找名为“Publication Title”(错误名称)的列,并将它们重命名为Title,除非列表名为“参与者”,在这种情况下,它重命名为“Last name”。改变口味