Hi!
In a project we got a requirement to hide the “Open with explorer view” from the ribbon, this can be done by PowerShell by creating a custom action in the library/list
The following code will be used to hide the action from the ribbon:
$sites = get-spwebapplication http://yourwebappurl | Get-spsite -limit ALL foreach ($site in $sites) { foreach ($web in $site.AllWebs) { foreach ($list in $web.Lists) { $CustomAction = $list.UserCustomActions.Add() $CustomAction.Title = "Hide Explorer View" $CustomAction.Location = "CommandUI.Ribbon" $CustomAction.commandUIExtension = " <CommandUIExtension> <CommandUIDefinitions> <CommandUIDefinition Location='Ribbon.Library.Actions.OpenWithExplorer' /> </CommandUIDefinitions> </CommandUIExtension>" $CustomAction.Update(); } } }
After the code has been executed, the action will disappear from the ribbon.
If you need to recover the action from the ribbon, the following PowerShell can be used for this:
$CustomActionTitle = "Hide Explorer View" $sites = get-spwebapplication http://yoururlwebapp | Get-spsite -limit ALL foreach ($site in $sites) { foreach ($web in $site.AllWebs) { foreach ($list in $web.Lists) { $CustomAction = $list.UserCustomActions | where {$_.title -eq $CustomActionTitle} #Delete the custom action from list if ($CustomAction) { $CustomAction.Delete() } } } }
That’s all!