Sitecore Stack Exchange is a question and answer site for developers and end users of the Sitecore CMS and multichannel marketing software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I wanted to know better way to reset Display Name to empty using PowerShell scripts.

I have written below script..

$item = Get-Item "/sitecore/content/home"
$item.Editing.BeginEdit()
$item["{B5E02AD9-D56F-4C41-A065-A133DB87BDEB}"] = ""
$item.Editing.EndEdit()

which works but I'm not sure its the correct way or not.

I also tried something like $item[Sitecore::FieldIDs::DisplayName] = "" which doesn't work ..

Please help.

share|improve this question
    
I'm using Sitecore 7.5 and Sitecore PowerShell Extensions 4.0.0.0 – Harsh Baid yesterday
up vote 7 down vote accepted

You can use this to set it to empty. With this you don't need to wrap the change with BeginEdit and EndEdit

$item."__Display Name" = "" 

You only need the quotes here as there is a space in the name, a field without a space can be accessed like so: $item.MyField

If you actually want to reset the field value, rather than explicitly set it as empty, use:

Reset-ItemField -Item $item -IncludeStandardFields -Name "__Display Name"
share|improve this answer
    
I'm getting this error The term 'Reset-ItemField' is not recognized as the name of a cmdlet I'm using Sitecore 7.5 and Sitecore PowerShell Extensions 4.0.0.0 – Harsh Baid yesterday
    
Hmm I think this command was in 4.0, I'm just checking that for you. – Kasaku yesterday
    
Yes this was in SPE 4.0. How did you confirm the SPE version? Did you use the About icon in the ribbon of ISE? – Kasaku yesterday
    
I have checked from file properties of Cognifide.PowerShell.dll assembly – Harsh Baid yesterday
1  
@Harsh and I resolved the issue above which was unrelated to the question in hand, he had a corrupt installation of 4.0 and reinstalling it gave access to the command. – Kasaku yesterday

Try this:

Reset-ItemField -Item $item -Name "__Display Name" -IncludeStandardFields

source: Reset-ItemField docs

share|improve this answer

This should do the trick:

Get-Item "master:/sitecore/content/home" | Reset-ItemField -IncludeStandardFields -Name "__Display Name"

See reference here. The IncludeStandardFields is needed as this field is a Sitecore standard field.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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