SharePoint Online: Configure Require Check Out Option using PowerShell
Requirement: Configure require check out settings in SharePoint Online.
Require check out option in SharePoint Online helps to avoid save conflicts when multiple users attempts to open and edit a document at the same time. Basically the Check out is a quick way to lock a document from editing by other users.
How to Enable Require Check Out for Document Libraries in SharePoint Online?
By default, the require checkout option is turned OFF. We can turn require check out option for a document library ON or OFF. Here is how:
PowerShell to Set Require Check Out in SharePoint Online
This PowerShell script enables Require Check out for all document libraries in given site collection in SharePoint Online.
How to Disable Check out in SharePoint Online?
If require checkout option is already enabled for a document library, we can disable it in bulk for all libraries in a site collection with this PnP PowerShell script.
Here is my another article discussing setting up Require check out option in SharePoint: Configure Require Check Out in SharePoint
Require check out option in SharePoint Online helps to avoid save conflicts when multiple users attempts to open and edit a document at the same time. Basically the Check out is a quick way to lock a document from editing by other users.
How to Enable Require Check Out for Document Libraries in SharePoint Online?
By default, the require checkout option is turned OFF. We can turn require check out option for a document library ON or OFF. Here is how:
- Go to your SharePoint Online document library.
- Click on Settings >> Library Settings
- On Document Library Settings page, Click on Versioning settings
- Scroll down to the bottom of the page. Under Require Check out section, select "Yes" for
"Require documents to be checked out before they can be edited?" option to enable check out. Similarly, to disable check out in SharePoint Online, select the "No" option.
- Click "OK" to save your changes.
PowerShell to Set Require Check Out in SharePoint Online
This PowerShell script enables Require Check out for all document libraries in given site collection in SharePoint Online.
#Load SharePoint CSOM Assemblies Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll" Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll" Function Set-SPORequireCheckout([String] $SiteURL,[Boolean] $RequireCheckout) { Try { #Setup the context $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL) $Ctx.Credentials = $Credentials #Get the web and Its subsites from given URL $Web = $Ctx.web $Ctx.Load($Web) $Ctx.Load($Web.Lists) $Ctx.Load($web.Webs) $Ctx.executeQuery() #Filter Document Libraries from Lists collection $DocumentLibraries = $Web.Lists | Where {$_.BaseType -eq "DocumentLibrary" -and $_.Hidden -eq $False} Write-host -f Yellow "Processing Site:" $SiteURL #Loop through each document library and set require checkout option Foreach ($DocumentLibrary in $DocumentLibraries) { #Require documents to be checked out before they can be edited $DocumentLibrary.ForceCheckout=$RequireCheckout $DocumentLibrary.Update() $Ctx.ExecuteQuery() Write-host -f Green "`t Require Checkout has been Configured for" $DocumentLibrary.Title } #Iterate through each subsite of the current web ForEach ($Subweb in $Web.Webs) { #Call the function recursively Set-SPORequireCheckout $Subweb.url $RequireCheckout } } Catch { write-host -f Red "Error:" $_.Exception.Message } } #Config Parameters $SiteCollURL="https://crescenttech.sharepoint.com" $RequireCheckout = $True #Setup Credentials to connect $Cred= Get-Credential $Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password) #Call the function to Set Require Checkout for All document libraries in the site collection Set-SPORequireCheckout $SiteCollURL $RequireCheckout
How to Disable Check out in SharePoint Online?
If require checkout option is already enabled for a document library, we can disable it in bulk for all libraries in a site collection with this PnP PowerShell script.
#Function to Disable Checkout Option for all libraries ina site Function Disable-PnPRequireCheckout { param ( [parameter(Mandatory = $true, ValueFromPipeline = $True)]$Web ) Try { Write-host "Processing Web:"$Web.URL -f Magenta #Array to exclude system libraries $SystemLibraries = @("Form Templates", "Pages", "Preservation Hold Library","Site Assets", "Site Pages", "Images", "Site Collection Documents", "Site Collection Images","Style Library","Drop Off Library") $Libraries = Get-PnPList -Web $Web -Includes BaseType, Hidden, EnableVersioning -ErrorAction Stop #Get All document libraries $DocumentLibraries = $Libraries | Where {$_.BaseType -eq "DocumentLibrary" -and $_.Hidden -eq $False -and $_.Title -notin $SystemLibraries} #Disable Checkout ForEach($Library in $DocumentLibraries) { If($Library.ForceCheckout) { #Powershell to disable checkout for the library Set-PnPList -Identity $Library -Web $Web -ForceCheckout $false Write-host -f Green "`tRequire Check-out disabled on '$($Library.Title)'" } Else { Write-host -f Yellow "`tRequire Check Out is already set to 'No' at '$($Library.Title)'" } } } Catch { Write-host -f Red "`tError:" $_.Exception.Message } } #Parameters $SiteURL = "https://crescentintranet.sharepoint.com/sites/marketing" #Connect to PnP Online Connect-PnPOnline -URL $SiteURL -UseWebLogin #Call the function for Root web Get-PnPWeb | Disable-PnPRequireCheckout #Get All Sub-Webs in the site collection call the function to disable checkout Get-PnPSubWebs -Recurse | ForEach-Object { Disable-PnPRequireCheckout $_ }
Here is my another article discussing setting up Require check out option in SharePoint: Configure Require Check Out in SharePoint
When adding a document to the Library from Onedrive, it is already checked-in, is this something that can be forced to be checked out as well?
ReplyDelete