How to Check Out Documents in SharePoint

Are you trying to check out your SharePoint Online documents?

Checking out documents in SharePoint means reserving a document for exclusive editing. This feature is particularly useful when multiple team members are working on the same document.

Checking out a document helps you prevent others from making changes simultaneously, effectively eliminating the risk of conflicting edits or overwrites.

This guide will walk you through the process of checking out documents on SharePoint Online.

What is a Checked-Out Document?

A checked-out document in SharePoint Online is a status indicator that shows a file is currently being worked on by a specific user. When a document is checked out, it is locked for editing by anyone else, preventing multiple users from making conflicting changes simultaneously.

This feature ensures version control and helps avoid data overwrites, which is especially important when multiple team members collaborate on the same document.

Checking out a document means that you have exclusive editing rights for that file, and others can only view it until you check it back in.

This control mechanism is crucial for maintaining data integrity and preventing accidental or unauthorized modifications.

In this article, we’ll explore the various ways to check out documents in SharePoint Online, helping you take full advantage of this functionality for smoother collaboration and document management.

Check-Out Document from Document Library

To check-out document in SharePoint online, follow these steps:

  1. Login to your office 365 account (tenant)
  2. Click on App launcher at the top left corner of your page.
  3. Click on SharePoint.

This will take you to your SharePoint Home page. Select your desired team site containing the documents you want to check out.

  1. Click on Document. This will take you to the document library.
  1. Present inside the document library, click on the folder where the documents you want to check-out are located.

This will display all the documents present in that folder.

  1. Click on the document you want to check out. This will display a panel.
  2. Click on More on the displayed panel.
  3. Click on check out.

This will check out the document. Once the document is checked out, you’ll get a tiny outward-pointing red arrow in the document icon. You’ll also get a notification pop up on the screen showing the document that was checked out.

Also, you can check out multiple documents my selecting all the documents you want to check out at once using the radio buttons on the left side of the name column:

After selecting all the documents, click on the three dots and click on check out. This will successfully check out all the selected documents. Also, a notification will display showing the selected documents that were checked out.

Check-Out Documents using a PowerShell Script

PowerShell allows you to automate and simplify various tasks, including checking out documents, making it an efficient choice for users who prefer command-line interfaces.

With PowerShell, you can check out multiple documents simultaneously, making it a time-saving solution for those handling large sets of files or managing documents programmatically.

Whether you’re an IT professional, a developer, or simply looking for a streamlined approach, this method can be a valuable addition to your toolkit.

Follow these steps to check-out documents in SharePoint Online using PowerShell Script.

# 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"
  1. Open your PowerShell and Load SharePoint CSOM assemblies. This is necessary to interact with SharePoint online. Click enter on your keyboard afterward.
# Function to Check out a file from a given URL
Function Checkout-Document($SiteURL, $FileRelativeURL, $Credentials)
{
    # Setup the context
    $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
    $Ctx.Credentials = $Credentials

    Try {
        # Try to get the File from the URL
        $File = $Ctx.Web.GetFileByServerRelativeUrl($FileRelativeURL)
        $Ctx.Load($File)
        $Ctx.ExecuteQuery()

        # Check if the file is already checked out
        If ($File.CheckOutType -ne "None") {
            write-host "File is already checked-out!" -f Yellow
            break
        }
        # Checkout the document
        $File.CheckOut()
        $Ctx.ExecuteQuery()

        write-host "Document has been checked out successfully!" -f Green
    }
    Catch {
        write-host -f Red "Error checking out Document!" + $_.Exception.Message
    }
}
  1. Define the function. This function `checkout-Document` takes three parameters:
  • $SiteURL: The URL of the SharePoint site.
  • $FileRelativeURL: The relative URL of the document to check out.
  • $Credentials: The credentials for connecting to SharePoint Online.

It establishes a connection to SharePoint Online, attempts to retrieve the document, checks if the document is already checked out, and if not, checks it out.

# Default Parameters
$SiteURL = "https://your-sharepoint-site-url/"
$FileRelativeURL = "/sites/YourSite/YourLibrary/YourDocument.docx"
$Username = "your-username"
$Password = "your-password"
  1. Next, you can replace https://your-sharepoint-site-url/”, “/sites/YourSite/YourLibrary/YourDocument.docx, your-username, and your-password with the appropriate values for your SharePoint Online environment.
# Call the function to Checkout file
Checkout-Document -SiteURL $SiteURL -FileRelativeURL $FileRelativeURL -Credentials $Credentials
  1. You’ll call Checkout-Document function with the defined parameters to checkout document.

This PowerShell script will successfully check out the selected document used in the script. Make sure you input the correct parameters not to run into errors.

To check out multiple documents in SharePoint online, you can modify the above script slightly to iterate through a list of document URLs and check them out one by one. Here is the modified script with the necessary steps:

# 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 to Check out a list of documents from a given URL
Function Checkout-MultipleDocuments($SiteURL, $FileRelativeURLs, $Credentials)
{
    # Setup the context
    $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
    $Ctx.Credentials = $Credentials

    Try {
        foreach ($FileRelativeURL in $FileRelativeURLs) {
            # Try to get the File from the URL
            $File = $Ctx.Web.GetFileByServerRelativeUrl($FileRelativeURL)
            $Ctx.Load($File)
            $Ctx.ExecuteQuery()

            # Check if the file is already checked out
            If ($File.CheckOutType -ne "None") {
                write-host "File at $FileRelativeURL is already checked out!" -f Yellow
            }
            else {
                # Checkout the document
                $File.CheckOut()
                $Ctx.ExecuteQuery()
                write-host "Document at $FileRelativeURL has been checked out successfully!" -f Green
            }
        }
    }
    Catch {
        write-host -f Red "Error checking out Documents!" + $_.Exception.Message
    }
}

# Default Parameters
$SiteURL = "https://your-sharepoint-site-url/"
$FileRelativeURLs = @(
    "/sites/YourSite/YourLibrary/Document1.docx",
    "/sites/YourSite/YourLibrary/Document2.xlsx",
    "/sites/YourSite/YourLibrary/Document3.pdf"
)
$Username = "your-username"
$Password = "your-password"

# Convert password to secure string
$SecurePassword = ConvertTo-SecureString $Password -AsPlainText -Force

# Create credentials
$Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $SecurePassword)

# Call the function to checkout multiple documents
Checkout-MultipleDocuments -SiteURL $SiteURL -FileRelativeURLs $FileRelativeURLs -Credentials $Credentials

In the modified script:

  1. The Checkout-MultipleDocuments function accepts an array of document URLs ($FileRelativeURLs) instead of a single URL. It iterates through the array, checking out each document one by one.
  2. Default parameters are set for the SharePoint site URL, an array of document URLs, username, and password. Users can replace these default parameters with their specific values.
  3. The script loops through the array of document URLs, checks if each document is already checked out, and if not, checks it out.

In some cases, you might need to check out documents from their Item ID rather than using the document URL. To do this, you can use the following PowerShell script to check out a document based on its Item ID:

#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"
   
#Set Variables for Site URL, Library Name and Item ID
$SiteURL= "https://your-sharepoint-site-url/"
$LibraryName="Documents"
$ItemID="4"
 
#Setup Credentials to connect
$Cred = Get-Credential
$Cred = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.UserName,$Cred.Password)
 
#Setup the context
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Ctx.Credentials = $Cred
 
#Get the web, List, Item adn File
$Web=$Ctx.Web
$List=$web.Lists.GetByTitle($LibraryName)
$Item=$list.GetItemById($ItemID)
$File=$Item.File
 
#Check out the file
$File.CheckOut()
$Ctx.ExecuteQuery()

📝 Note: Some time you might accidentally check-out a document. To discard the checked-out document, right click on the document you accidentally checked out, click on more and finally click on Discard check out.

Check Out Wiki Pages

In SharePoint, wiki pages serve as a versatile tool for creating and sharing information within your organization.

These pages are dynamic and can be edited collaboratively, but there are scenarios where you may need to ensure that only one person can edit a wiki page at a time. This is where the document checkout feature comes in handy.

📒Read More: Check out this post to learn how to create a wiki page in SharePoint.

Follow these steps to checkout your wiki page:

  1. Enter your desired SharePoint site where you have created your wiki page.
  2. Click on Site Contents at button left corner of your page.
  3. Scroll down and click on Site Pages at the button.

This will display all the wiki pages present on that site.

  1. Click on the wiki page you want to check out. This will display a panel.
  2. Click on More on the displayed panel.
  3. Click on check out.

This will check out the wiki page. Once the wiki page is checked out, you’ll get a tiny outward-pointing red arrow in the document icon. You’ll also get a notification popup on the screen showing the wiki page that was checked out.

Also, you can check out multiple wiki pages my selecting all the wiki you want to check out at once using the radio buttons on the left side of the name column:

After selecting all the wiki page, click on the three dots and click on check out. This will successfully check out all the selected wiki pages. Also, a notification will display showing the selected wiki pages that were checked out.

Conclusions

Mastering the art of checking out documents in SharePoint Online is a pivotal skill for efficient document management and seamless collaboration.

Understanding the various methods, from the user-friendly web interface to the automation capabilities of PowerShell, you can tailor your approach to suit your unique requirements.

Additionally, the ability to check out wiki pages adds an extra layer of control to dynamic content.

With these tools at your disposal, you’re well-prepared to enhance your document management experience, prevent conflicts, and collaborate effectively within your organization.

About the Author

Durojaye Olusegun

Durojaye Olusegun

Durojaye is a cybersecurity professional and data analyst with a knack for distilling complex technical information into simple, digestible guides. His diverse skill set not only covers the intricate world of cybersecurity but also delves into the realm of Microsoft 365 tools. Whether he's crafting informative blog posts or engaging social media content, or staying updated on the latest trends in his field, Durojaye always brings a unique perspective to his work.

Related Articles

Comments

0 Comments

Submit a Comment

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

Get the Latest Tech Tips

Write For Us

Are you a tech enthusiast with a talent for writing great content? Come write for us!

Follow Us

Follow us on social media to stay up to date with the latest in tech!