Trying to add a keyword to the keyword-multilist field with SPE.

$items = Get-ChildItem -Path "master:\sitecore\content\Website\site\subnode" -Recurse
$items | ForEach-Object {
    [Sitecore.Data.Fields.MultilistField]$field = $items.Fields["Keywords"]


The idea is to add the same keyword for each item below the subnode, and to every language version. An item can occure in more than one language, and the keywords-section can be empty or have one or more values. SPE returns "You cannot call a method on a null-valued expression." - so I'm kinda stuck...

1 Answer 1


With a lot of help from Sitecore friends, this is the solution:

#The guid of the keyword needed to be appended: {6D1EACDD-0DE7-4F3D-B55A-2CAE8EBFF3D0} 

$items = Get-ChildItem -Path "master:\sitecore\content\home" -Recurse -Language * 
foreach($item in $items) {
$item.Keywords = (@() + $item.Keywords.GetItems().ID    + "{6D1EACDD-0DE7-4F3D-B55A-2 CAE8EBFF3D0}" | Select-Object -Unique) -join "|" 

So thanks a lot for the help to Kamruz Jaman, Mike Ian Reynolds, Michael West and Adam Najmanowicz!

The book now contains updated examples.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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