0

Want to know how to hide New Document command from ribbon using PowerShell in SP 2013.

Below is my code that does not work.

$CustomAction = $list.UserCustomActions.Add()
$CustomAction.Title = "Hide New Document"
$CustomAction.Location = "CommandUI.Ribbon"
$CustomAction.commandUIExtension = "
     <CommandUIExtension> 
         <CommandUIDefinitions> 
             <CommandUIDefinition Location='Ribbon.Library.Actions.NewDocument' /> 
         </CommandUIDefinitions>
     </CommandUIExtension>" 
$CustomAction.Update()
2

You specified a wrong Id. Use Ribbon.Documents.New.NewDocument instead of Ribbon.Library.Actions.NewDocument. Your code should look like this:

$CustomAction = $list.UserCustomActions.Add()
$CustomAction.Title = "Hide New Document"
$CustomAction.Location = "CommandUI.Ribbon"
$CustomAction.commandUIExtension = "
     <CommandUIExtension> 
         <CommandUIDefinitions> 
             <CommandUIDefinition Location='Ribbon.Documents.New.NewDocument' /> 
         </CommandUIDefinitions>
     </CommandUIExtension>" 
$CustomAction.Update()

You can find the full list of locations here: C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\TEMPLATE\GLOBAL\XML\CMDUI.xml

  • Hello Paul.your code worked!Thanks very much.One question I have, now its hidden,how to go back to show this again? – userAZLogicApps Jun 20 '15 at 12:49
  • Remove the custom action. – Paul Strupeikis Jun 22 '15 at 8:23
  • API for the same? – userAZLogicApps Jun 22 '15 at 8:24
  • 1
    There is no Remove() method. You need to remove the custom action from the collection this way: $list.UserCustomActions[action.Id].Delete(); $list.Update(); – Paul Strupeikis Jun 22 '15 at 8:39
  • 1
    No. There is a property called "Id". You set it when creating a custom action. $CustomAction.Id = "MyCustomActionID". – Paul Strupeikis Jun 22 '15 at 9:51

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.