Rename Content Type Name using PowerShell
$siteUrl = "http://YourServerName/sites/testsite" [system.reflection.assembly]::LoadWithPartialName("Microsoft.Sharepoint") > $null
#get the SPSite
$site = New-Object Microsoft.SharePoint.SPSite($siteUrl)
#Get the root web
$RootWeb = $site.RootWeb
#Find the list in the root web
$mylistname ="TheNameOfTheList"
$myList= $RootWeb.Lists[$mylistname]
if ($myList -ne $null)
{
$myContentType = $myList.ContentTypes["ExampleCT"]
if ($myContentType -ne $null)
{
$myContentType.Name = "Example CT"
$myContentType.Update()
}
}
$siteUrl = "http://YourServerName/sites/testsite" [system.reflection.assembly]::LoadWithPartialName("Microsoft.Sharepoint") > $null
#get the SPSite
$site = New-Object Microsoft.SharePoint.SPSite($siteUrl)
#Get the root web
$RootWeb = $site.RootWeb
#Find the list in the root web
$mylistname ="TheNameOfTheList"
$myList= $RootWeb.Lists[$mylistname]
if ($myList -ne $null)
{
$myContentType = $myList.ContentTypes["ExampleCT"]
if ($myContentType -ne $null)
{
$myContentType.Name = "Example CT"
$myContentType.Update()
}
}
No comments:
Post a Comment