VIDEO – Toggle Required Fields OFF

When making bulk data changes to SharePoint List or Library you may need to temporarily turn off Required fields.   Opening this can allow us to import records, apply changes, and modify metadata without prompting that required fields are missing.   PowerShell below can help disable all Required fields OFF.    Script generates a CSV snapshot of prior configuration during run.    CSV can be used to restore original configuration for which fields are Required.

Cheers shades_smile


PowerShell Code

param (
# Module
Import-Module "SharePointPnPPowerShellOnline" -ErrorAction "SilentlyContinue" | Out-Null
# Config
$appid = "APP ID HERE"
$appsecret = "APP SECRET HERE"
function Main() {
    # Connect
    Connect-PnPOnline -Url "" -AppId $appid -AppSecret $appsecret 
    $ctx = Get-PnPContext
    $list = Get-PnPList "Test"
    if ($restoreFilename) {
        # ENABLE Required Fields
        $csv = Import-Csv $restoreFilename
        $fields = Get-PnPField -List $list
        foreach ($row in $csv) {
            $f = $fields | ? { $_.Id -eq $row.Guid }
            $f.Required = $true
    else {
        # DISABLE Required Fields
        $coll = @()
        $guid = (New-Guid).ToString()
        $fields = Get-PnPField -List $list
        foreach ($f in $fields) {
            if ($f.Required) {
                Write-Host "CHANGED FIELD $($f.Title) NOT REQUIRED"
                $f.Required = $false
                $coll += $f.Id
        $coll | Export-Csv "PNPToggleRequiredField-$guid.csv"
# Main

GitHub Link


Return to Top ▲Return to Top ▲