Monday, April 11, 2016

Change Column Type in SharePoint List using PowerShell

param(
[String]$ConfigPath = $(throw "Configuration object required to execute script."),
[String]$LocalesPath = $(throw "Settings object required to execute script.")
)
#################################################################################

$configSettings = New-Object -TypeName XML
$configSettings.Load($ConfigPath)

$localeSettings = New-Object -TypeName XML
$localeSettings.Load($LocalesPath)


##Script to run : .\Update-EventContentType.ps1 -ConfigPath "Full Path Configuration File" -LocalesPath "Full Path of Settings File"


function Update-FieldVideo {
    param(
   [string] $SiteUrl
    )
$site = Get-SPSite $SiteUrl
$web = $site.RootWeb

        $ct = $site.RootWeb.ContentTypes["Intranet Video News"]
write-Host "content Type Found"  -foregroundcolor green
write-Host "Update Field Display Name Start"  -foregroundcolor green

        $location = $ct.FieldLinks["IntranetVideoText2"]
        $location.Type = [Microsoft.SharePoint.SPFieldType]::Note

$desc = $ct.FieldLinks["IntranetVideoText1"]
        $desc.Type = [Microsoft.SharePoint.SPFieldType]::Note //FOR THIS PART CHECK ANOTHER ARTICLE FOR FIELD TYPE IN POWERSHELL

$ct.Update($true)

write-Host "Update Field Display Name End"  -foregroundcolor green
}


foreach ($sc in $configSettings.Config.SiteCollections.ChildNodes) {

    if($sc.IsRootHNSC -ne "true"){
        $SiteUrl = "{0}/{1}/{2}" -f $localeSettings.Settings.HNSC_HostHeader,$localeSettings.Settings.HNSC_ManagedPath,$sc.SiteUrl
#Update-FieldList -SiteUrl $SiteUrl
#Update-FieldOrder -SiteUrl $SiteUrl
#Update-contentTypeList -SiteUrl $SiteUrl
Update-FieldVideo -SiteUrl $SiteUrl
       }
}

No comments:

Post a Comment