6

I have a rich text field in my user defined template and I want to replace the source value of the rich text field. Below is my query where I'm able to read Name, type etc, however $_.source is something which returns nothing though the source value still exists. Any help please.

$targetTemplate    = Get-Item 'master:/sitecore/templates/User Defined/Common/Data';
$templateFilter    = Get-Item "master:/sitecore/templates/System/Templates/Template Field";

Get-ChildItem $targetTemplate.FullPath -recurse 
| Where-Object { $_.TemplateName -eq $templateFilter.Name -and $_.type -eq 'Rich Text'} 
| ForEach-Object {
    $($_.source)
    #$_.Name
    #$_.Type
}

1 Answer 1

6

Change your script in a following way:

$targetTemplate    = Get-item 'master:/sitecore/templates/User Defined/Common/Data';
$templateFilter    = Get-Item "master:/sitecore/templates/System/Templates/Template Field";


Get-ChildItem $targetTemplate.FullPath -recurse | Where-Object { $_.TemplateName -eq $templateFilter.Name -and $_.type -eq 'Rich Text'} | ForEach-Object {
    $_._Source # <- Here's the change, added underscore before the Source
    $_.Name
    $_.Type
}
3
  • 1
    $_."_Source" also possible in place of $_["Source"]
    – Harsh Baid
    Commented Sep 28, 2016 at 11:12
  • Thanks a lot. Why source is different from Name and type. Commented Sep 28, 2016 at 11:14
  • Hmmm, can't remember exactly why, but you can do it even simpler: $_._Source. Maybe there is a name conflict or something like that? I have updated my answer. Commented Sep 28, 2016 at 11:33

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.