I have set a value in a General link field in a Sitecore item using PowerShell. Here is the PowerShell script.


[Sitecore.Data.Fields.LinkField]$fieldValueLink = $Item.Fields[$templateField.DisplayName]

$fieldValueLink.Text = "Link"
$fieldValueLink.Title = "click on the link"
$fieldValueLink.LinkType = "external"
$fieldValueLink.Url = $itemRow.$fieldTrimmedValue

$item[$templateField.DisplayName] = $fieldValueLink.Value;

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

Now I want to set values into other field types like DropLink, Multilist and DropList. For setting these field values I think I need to create Sitecore items using PowerShell and then assign them to the fields' values, But I don't know where to start and how to proceed.

Can anyone help me out with this?

1 Answer 1


To create a new item with Sitecore Powershell Extensions, use New-Item:

$newItemParentPath = "/sitecore/content/Home"
$newItemTemplate = "{76036F5E-CBCE-46D1-AF0A-4143F9B557AA}"

$newItem = New-Item -Path $newItemParentPath -Name "New Item Name" -ItemType $newItemTemplate

Now to assign that new item in Droplink field you need to assign ID of that item to the field like:

$item["Droplink field name"] = $newItem.ID

and to assign that new item in Droplist field you need to assign Name of that item to the field like:

$item["Droplist field name"] = $newItem.Name
  • If i want to add a datasource which has more items then, should i need to add give value for sort. Or please tell me how to add list of items to a droplink field. Jul 5, 2019 at 13:57
  • I'm trying something like this. $item.Editing.BeginEdit() $allItems = Get-ChildItem -Path '/sitecore/content/ListManagerTask' -Recurse foreach($droplinkItem in $allItems){ $item[$templateField.DisplayName] = $droplinkItem.ID; } $item.Editing.EndEdit() | Out-Null Jul 5, 2019 at 13:59
  • So you take some item ($item) and then you iterate after ListManagerTask and all its descendants and in every loop you assign ID of that descendant to the same field. So after your loop is done, it will be the last descendant assigned to $item[$templateField.DisplayName] field, right? Btw, don't use DisplayName here, use Name or ID.
    – Marek Musielak
    Jul 5, 2019 at 14:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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