Search for Check-In and Check out files in Sharepoint Document Library

Jefferson Co 181 Reputation points


We have a customer who doesn't have a file server and their only file storage is Microsoft SharePoint. One of their staff is having a hard time monitoring the files whether they're Check-In or Check-out. Made my research and found a set of cmdlets on how to do this but for some reason every time I type in the comdlet 'Get-SPWeb', it doesn't recognized and every time I typed in Add-snap-ins Microsoft.Sharepoint.Powershell shows 'No snap-ins have been registered.

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue


$LibraryURL="/Shared%20Documents" #Relative URL

Get Objects

$Web = Get-SPWeb $WebURL
$Folder = $web.GetFolder($LibraryURL)

Function to find all checked out files in a SharePoint library

Function CheckIn-CheckedOutFiles($Folder)

$Folder.Files | Where { $_.CheckOutStatus -ne "None" }  | ForEach-Object {
write-host ($_.Name,$_.URL,$_.CheckedOutBy)

#To Check in
$_.Checkin("Checked in by Administrator")

Process all sub folders

$Folder.SubFolders | ForEach-Object {
CheckIn-CheckedOutFiles $_

Call the function to find checkedout files

CheckIn-CheckedOutFiles $Folder

Read more:


A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
9,202 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,281 questions
0 comments No comments
{count} votes

Accepted answer
  1. Amos Wu-MSFT 4,051 Reputation points

    The script you shared can run normally in my environment.
    The way to solve "The term ‘Get-SPWeb’ is not recognized as the name of a cmdlet, function" PowerShell error is to add

    Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue  

    More reference:
    If you are using SharePoint Online,you could referto this blog:


    $username = ""  
    $password = "Password"  
    $cred = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $userName, $(convertto-securestring $Password -asplaintext -force)  
    Connect-PnPOnline -Url -Credentials $cred  
    $list=Get-PnPList "lib"  
    $allDocs = (Get-PnPListItem -List $list)   
            foreach ($doc in $allDocs) {  
                if ($null -ne $doc.FieldValues.CheckoutUser.LookupValue) {  
                    write-host $doc.FieldValues.FileRef  
                    Set-PnPFileCheckedIn -Url $doc.FieldValues.FileRef  

    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments

5 additional answers

Sort by: Most helpful
  1. Jefferson Co 181 Reputation points

    I did run both cmdlets

    Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
    Add-PSSnapin Microsoft.SharePoint.PowerShell

    But both showed 'No Snap-ins have been registered

    I tried installing both as well

    Install-Module -Name Microsoft.Online.SharePoint.PowerShell -RequiredVersion 16.0.8414.1200

    Import-Module Microsoft.Online.SharePoint.Powershell -Verbose

    Same issue

  2. Jefferson Co 181 Reputation points

    I think I'm getting progress. I used the script below

    $username = "correct_username"
    $password = "correct _password"
    $cred = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $userName, $(convertto-securestring $Password -asplaintext -force)
    Connect-PnPOnline -Url https://<site name> -Credentials $cred
    $list=Get-PnPList "lib"
    $allDocs = (Get-PnPListItem -List $list)

          foreach ($doc in $allDocs) {
               if ($null -ne $doc.FieldValues.CheckoutUser.LookupValue) {
                    write-host $doc.FieldValues.FileRef
                    print $doc.FieldValues.CheckoutUser.LookupValue

    Initially prompted me that Connect-PnPOnline is not recognized, I did "Install-Module -Name SharePointPowerShellOnline" and that resolved the Connect-PnPOnline not recognize issue but came up with

    Connect-PnPOnline : The sign-in name or password does not match one in the Microsoft account system.
    At line:1 char:1

    Does this has something to do with 2FA?


    0 comments No comments

  3. Jefferson Co 181 Reputation points

    Ok, so I used -UseWebLogin instead of cred because we do have 2FA enabled. Got past through that and another error message came up

    Get-PnPListItem : Cannot bind argument to parameter 'List' because it is null.
    At line:6 char:38

    • $allDocs = (Get-PnPListItem -List $list)
    • ~~~~~
    • CategoryInfo : InvalidData: (:) [Get-PnPListItem], ParameterBindingValidationException
    • FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,PnP.PowerShell.Commands.Lists.GetListItem

  4. Jefferson Co 181 Reputation points

    Sorry accidentally clicked on 'Report a concern' I was trying to see if we can have a Teams chat or somehow a faster communication, I really appreciate the help but seems like it's not working as what you're showing me on your screen captures.