You can list all external users for the entire SharePoint Online tenant by using following option.
Method 1: Use PnP PowerShell to list all external users.
Connect-PnPOnline -Url "https://tenant-admin.sharepoint.com"
For more details use this link List external users
Method 2: Use graph api to list all external users
If user has permissions on Site Pages library
If user has permissions on site pages library, check user permissions on individual site pages
If user has permissions on Site Pages library:
Go to Site pages library
Click on settings (gear icon)
Select Library settings
Select Permissions for this document library
Check if site pages library ...
You can assign permissions to SharePoint group using SharePoint REST API like:
url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/roleassignments/addroleassignment(principalid=<GroupId>, roledefid=1073741827)",
Steps to solve your problem,
Go to library settings
In permission and management > click on Manage files which have no checked in version
When you see list of checked out files
Take ownership of selection > select the document for which you want to take ownership
Delete it or update it, it's up to you 🙂
I didn't do this by my self > not unit ...