In 2 proven ways to disable attachments SharePoint list instantly – In this article, we will learn how we can disable or enable attachments to list items in SharePoint Online in two ways:
- Disable attachments in the SharePoint list using the list advanced settings page
- Disable attachments in the SharePoint list using the PnP PowerShell
Disable attachments SharePoint list – attach file in SharePoint list
By default, attachments are enabled on the SharePoint list. So while creating a new item we get the “attach File” button in the ribbon. However, in many business use cases, we don’t need this – then can we disable it?
However, we can control the “Attach File” button, I mean we can disable or enable attachments to list items both in SharePoint Online and SharePoint On-Premise.
Disable attachments SharePoint list step-by-step process
Let’s see how we can do this. Navigate to the list setting page -> Advanced settings – click here.
Go to the “Attachments” section – by default attachments will be enabled as below:
- Attachments to list items are: Enabled
Change the above “Attachments” section – to disabled as below:
- Attachments to list items are: Disabled
Click on the OK button from the bottom of the page.
Warning message!!!
Please read the below message carefully – before disabling, if we have any attachments already in that particular list, all attachments will be deleted. If you are fine with this then only click Ok.
Navigate to the All Items view of the same list – click the new item button, we can see the “Attach File” button is not available anymore in the ribbon.
By now we have learned how to disable attachments in the SharePoint list from the list advanced settings page, now in the below section, we will learn how to disable attachments in the SharePoint list using the PnP PowerShell.
Disable attachments in SharePoint list using PnP PowerShell – disable attachments SharePoint list
Using the below PnP PowerShell we can disable the attachments in the SharePoint Online list:
####The below script is used to disable the attachments option in SharePoint Online list############# cls $PSshell = Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorVariable err -ErrorAction SilentlyContinue if($PSshell -eq $null) { Add-PSSnapin "Microsoft.SharePoint.PowerShell" } $fileName = "LogDisableAttachmentsinSPOList" #'yyyyMMddhhmm yyyyMMdd $enddate = (Get-Date).tostring("yyyyMMddhhmmss") #$filename = $enddate + '_VMReport.doc' $logFileName = $fileName +"_"+ $enddate+"_Log.txt" $invocation = (Get-Variable MyInvocation).Value $directoryPath = Split-Path $invocation.MyCommand.Path $directoryPathForLog=$directoryPath+"\"+"LogFiles" if(!(Test-Path -path $directoryPathForLog)) { New-Item -ItemType directory -Path $directoryPathForLog #Write-Host "Please Provide Proper Log Path" -ForegroundColor Red } #$logPath = $directoryPath + "\" + $logFileName $logPath = $directoryPathForLog + "\" + $logFileName $isLogFileCreated = $False function Write-Log([string]$logMsg) { if(!$isLogFileCreated){ Write-Host "Creating Log File..." if(!(Test-Path -path $directoryPath)) { Write-Host "Please Provide Proper Log Path" -ForegroundColor Red } else { $script:isLogFileCreated = $True Write-Host "Log File ($logFileName) Created..." [string]$logMessage = [System.String]::Format("[$(Get-Date)] - {0}", $logMsg) Add-Content -Path $logPath -Value $logMessage } } else { [string]$logMessage = [System.String]::Format("[$(Get-Date)] - {0}", $logMsg) Add-Content -Path $logPath -Value $logMessage } } #Paramaters area $siteURL="https://globalsharepoint2020.sharepoint.com/" #Your Site URL should be here. $userName = "YourSPOUser@YourSPOTenant.sharepoint.com" #Your user name should be here. $passWord = "YourSPOPassword" #Your password should be here. $encPassWord = convertto-securestring -String $passWord -AsPlainText -Force $cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $userName, $encPassWord $listName="Employee" #Your list name should be here. #Paramaters area - Ends try { Connect-PnPOnline -Url $siteURL -Credentials $cred #Disable Attachments in the given list Set-PnPList -Identity $listName -EnableAttachments $False } catch { $ErrorMessage = $_.Exception.Message +"in disabling attachments in SPO list!:" Write-Host $ErrorMessage -BackgroundColor Red Write-Log $ErrorMessage }
Enable attachments SharePoint list using PnP PowerShell
To enable attachments back to the list using the below PnP PowerShell command:
#Enable attachments back to the list Set-PnPList -Identity $listName -EnableAttachments $True
Note:
- With the administrator account above PnP PowerShell script should be executed.
Summary: Disable or enable attachments to list items
Hence, in this article we have learned the below:
- How to disable or enable attachments to list items in SharePoint lists using the list settings page.
- How to disable or enable attachments to list items in SharePoint lists using the PnP PowerShell.
- How to enable attachments in SharePoint online list.
- How to disable attachments in SharePoint online list.
See Also: SharePoint Online tutorial for beginners step by step
You may also like the below SharePoint Online tutorials:
- Office 365: Getting started with SharePoint PnP PowerShell – installation
- In 2 steps convert a classic SharePoint page to modern using PnP
- Office 365: Retrieve hub sites and associated sites using PnP Powershell
- Create a modern team site using PnP PowerShell in SharePoint
- In 4 steps access SharePoint online data using postman tool
- SharePoint admin center: Learn SharePoint online administration in an hour – step by step
- SharePoint REST API: GET vs POST vs PUT vs DELETE vs PATCH
- Office 365: Understanding the hub site in SharePoint online
- Move default Attachment Column in SharePoint List New form in M365
