Disable attachments SharePoint list from the advanced settings page

2 proven ways Disable attachments SharePoint list instantly: Disable or enable attachments to list items in SharePoint Online

No comments

 50,383 total views,  5 views today

How to disable a WordPress plugin v...
How to disable a WordPress plugin via Filezilla

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?

Disable attachments SharePoint list - SharePoint Online

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.

Disable attachments SharePoint list step by step

Go to the “Attachments” section – by default attachments will be enabled as below:

  • Attachments to list items are: Enabled

Disable attachments SharePoint list - Attachments enabled by default

Change the above “Attachments” section – to  disabled as below:

  • Attachments to list items are: Disabled

Disable attachments SharePoint list using the SharePoint list settings page

Click on the OK button from the bottom of the page.

Disable attachments SharePoint list from SharePoint list advanced settings 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.

Disabling attachment and saving the settings page - Disable attachments SharePoint list from SharePoint list advanced settings page

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.

Disable attachments SharePoint list - demo

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:

PDF Download Image

Download SharePoint Online & Office 365 Administration eBook

Buy the premium version of SharePoint Online & Office 365 administration eBook from here:



Buy SharePoint Online & Office 365 Administration eBook


 

Get the free demo PDF eBook from here:

FREE DOWNLOAD

Send download link to:

Subscribe to get exclusive content and recommendations every month. You can unsubscribe anytime.

About Post Author

Do you have a better solution or question on this topic? Please leave a comment