Sitecore powershell copy from one General Link field to another

 We have requirement to copy from one general link url to another field.

$allitems=Get-ChildItem -Path 'master://sitecore/content/Global -Recurse | Where-Object { $_.TemplateName -eq "Relatedcontent" }

  $allitems | ForEach-Object {     

       [Sitecore.Data.Fields.LinkField]$field = $_.Fields["Navigation Link"]

        [Sitecore.Data.Fields.LinkField]$fieldnew = $_.Fields["Navigation Link1"]

        $_.Editing.BeginEdit()               

        $fieldnew.LinkType=  $field.LinkType

         $fieldnew.TargetID=$field.TargetID

        $fieldnew.Url =$field.Url

        $_.Fields["NavigationTitle1"].Value=$_.Fields["NavigationTitle"].Value

        $_.Editing.EndEdit() | Out-Null     

        Write-Host $_.FullPath

}


Comments

Popular posts from this blog

Custom Item Url and resolving the item in Sitecore - Buckets

Fixing Sitecore Buckets folder path - Items created after 12 AM server time zone

Sitecore Search - API Crawler with Edge Pagination