Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Sitecore powershell, can you make an item unpublishable

In Sitecore Powershell for Sitecore 7.2...

Is it possible to set the "Publishable" rights on given items (to make them unpublishable)?

Specifically, I wish to automate the process of: selecting an item, opening Publish > Restrictions > Change, clicking the Item tab, and unchecking the "Publishable" box.

I've tried find that property of an item with no luck. I thought this might work, but "__Publishable" is not correct:

(get-item -Path master:/sitecore/content/Path/Home/About-Us)."__Publishable"

Is there a way to make Powershell report ALL of the properties of an item?

like image 931
Tim Grant Avatar asked Mar 15 '23 02:03

Tim Grant


1 Answers

The field for making an item un-publishable is:

__Never publish

So you could do this:

(get-item -Path master:/sitecore/content/DIAGlobal/Home/About-Us)."__Never publish"

Or if you wanted to edit it similar to back end code you could do:

$item = Get-Item master:/sitecore/content/DIAGlobal/Home/About-Us
$item.Editing.BeginEdit()
$item["__Never publish"] = "1"
$item.Editing.EndEdit()

Some good examples of how to read and edit fields with Powershell can be found here: http://blog.najmanowicz.com/2014/10/12/working-with-sitecore-items-in-powershell-extensions/

like image 178
Richard Seal Avatar answered Mar 30 '23 00:03

Richard Seal