문제

I would like to add multiple User Custom Actions on several sites using PowerShell. The custom actions must be added in the top ribbon that is visible when selecting a list item. Is that even possible? When looking at SPList userCustomActions property, it is readonly, according to MSDN . Am I taking the wrong path? The property is readonly but the custom actions are there, so they must have been added.

So far I've been there.

$w = get-spweb $webUrl;
$l = $w.lists[$listTitle];
$userCustomActions = $l.userCustomActions;

Of course, custom Actions can be added via JS, C# + feature, SharePoint Designer. But I can't use those methods, So I'm only interested in PowerShell procedures.

도움이 되었습니까?

해결책

You can use the UserCustomActions.Add() method to add the custom action.

Try and modify the below code:

$web = get-spweb $webUrl;
$list = $web.Lists[$listTitle];
$action = $list.UserCustomActions.Add();

$action.Url = "someurlhere";
$action.Location = "Ribbon.ListItem.Actions.Controls._children";
$action.Sequence = 85;
$action.Title = "Test Action";
$action.Description  = "Test Action description";

$action.Update();

MSDN - SPUserCustomActionCollection.Add

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 sharepoint.stackexchange
scroll top