Try with the below sample script:
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
#Variables
$WebURL="http://portal.globalsp.com"
$ListName="Documents"
#Get Objects
$Web = Get-SPWeb $WebURL
$List = $web.Lists.TryGetList($ListName)
If($List -ne $Null)
{
#Define CAML query to filter all checked out files
$Query = New-Object Microsoft.SharePoint.SPQuery
$Query.Query = "<Where>
<IsNotNull>
<FieldRef Name='CheckoutUser' />
</IsNotNull>
</Where>"
$Query.ViewAttributes = 'Scope="Recursive"'
$ListItems = $List.GetItems($Query)
Write-host "Total Number of Checked Out Files Found:"$ListItems.count
#Loop through each checked out File
ForEach ($Item in $ListItems)
{
Write-Host "'$($Item.Url)' is Checked out by: $($Item["CheckoutUser"])"
Check in
$Item.File.CheckIn("Checked in By Administrator!")
Write-Host -f Green "File Checked In!"
}
}
else
{
Write-Host -f Yellow "List '$ListName' Does not Exist!"
}
https://www.sharepointdiary.com/2013/02/find-all-checked-out-files-and-check-in.html
Thanks & Regards,