Show/hide the New button from a SharePoint Document Library

There are some scenarios where the document libraries on SharePoint are used only to upload files. For example, let’s say that you have a sales team that need to upload to a document library an excel every week. Therefore, maybe the new button to have an option to create a new folder or create a new document doesn’t make much sense.

So, if click on that button as admin of the SharePoint site and there is an option that allows you to edit that menu. If you remove all the option allow you to hide that menu which is exactly what we want. But let’s say that you need to apply that to multiple sites, you need to automate probably using Powershell. So we gonna use PnP PowerShell to configure that option.

# If you want to change between some option and other
# change visibility to true or false on the function DefaultMenuItems 
$list = "Documents"
$siteUrl = ""

function Add-MenuItem {
    $newChildNode = New-Object System.Object
    $newChildNode | Add-Member -type NoteProperty -name title -value $title
    $newChildNode | Add-Member -type NoteProperty -name visible -value $visible
    $newChildNode | Add-Member -type NoteProperty -name templateId -value $templateId

    return $newChildNode

function Get-DefaultMenuItems {
    $DefaultMenuItems = @()
    $DefaultMenuItems += Add-MenuItem -title "Folder" -templateId "NewFolder" -visible $true
    $DefaultMenuItems += Add-MenuItem -title "Word document" -templateId "NewDOC" -visible $true
    $DefaultMenuItems += Add-MenuItem -title "Excel workbook" -templateId "NewXSL" -visible $true
    $DefaultMenuItems += Add-MenuItem -title "PowerPoint presentation" -templateId "NewPPT" -visible $true
    $DefaultMenuItems += Add-MenuItem -title "OneNote notebook" -templateId "NewONE" -visible $true
    $DefaultMenuItems += Add-MenuItem -title "Visio drawing" -templateId "NewVSDX" -visible $true
    $DefaultMenuItems += Add-MenuItem -title "Forms for Excel" -templateId "NewXSLForm" -visible $true
    $DefaultMenuItems += Add-MenuItem -title "Link" -templateId "Link" -visible $true
    return $DefaultMenuItems

Connect-PnPOnline -Url $siteUrl -UseWebLogin

$list = Get-PnpList -Identity $ListTitle
$defaultView = Get-PnpView -List $List | Where-Object { $_.DefaultView -eq $true }
$MenuItems = Get-DefaultMenuItems
$defaultView.NewDocumentTemplates = $MenuItems | ConvertTo-Json


The SharePoint where you made this configuration will show or hide the Button. You can for instance apply this to a SharePoint Hub or to a list of SharePoint site.

If you need to add your own New option on this button, verify the following link:

One Comment

Leave a Reply

Your email address will not be published. Required fields are marked *