There is no PnP PowerShell to get External Sharing Infor, but the information is stored in the "Sharing Links" list in the site.
Below is a sample PowerShell code to parse the information from "Sharing Links" list:
$SiteURL = 'SiteURL'
Connect-PnPOnline -Url $SiteURL -Credential $credential -IgnoreSslErrors -WarningAction Ignore
$SharedLinks = get-pnplistitem -List "Sharing Links"
$InvitesAll = @()
$strCurrentTimeZone = (Get-WmiObject win32_timezone).StandardName
$TZ = [System.TimeZoneInfo]::FindSystemTimeZoneById($strCurrentTimeZone)
Function Get-LocalTime($UTCTime)
{
$LocalTime = ""
if ($UTCTime -ne $Null) {
$LocalTime = [System.TimeZoneInfo]::ConvertTimeFromUtc($UTCTime, $TZ)
}
Return $LocalTime
}
ForEach ($SharedLink in $SharedLinks) {
$SharedLinkInfo = $SharedLink['AvailableLinks'] | ConvertFrom-Json
foreach ($Invite in $SharedLinkInfo.Invitees) {
$InviteEmail = $Invite.Email
$InviteOn =$Invite.InvitedOn
$InviteBy = $users | Where {$.ID -eq $Invite.InvitedBy}
$InviteType = $Invite.Type #1 Is Existing user, #3 New user
if ($Invite.Type -eq 1) {
$InviteFoundinUIL = $users | Where {$.Id -eq $Invite.PId}
$InviteEmail= $InviteFoundinUIL.Email
}
else {
$InviteFoundinUIL = $users | Where {$.Email -eq $InviteEmail}
}
if ($InviteFoundinUIL) {
$inUIL = "True"
}
else {
$inUIL = "False"
}
$GuestType = ""
if ($InviteEmail -match '<tenant domain>') {
$Type = "Internal"
}
else {
$Type = "External"
if ($InviteFoundinUIL) {
if ($InviteFoundinUIL.LoginName -match '.onmicrosoft.com') {
$GuestType = "AzureADGuest"
}
else {
$GuestType = "urn:spo:guest"
}
}
}
#Conver InvitedOn Date/Time to local Time
if ($InviteOn -ne $Null) {
$InviteOn = (Get-LocalTime -UTCTime $InviteOn).toString("MM/dd/yyyy HH:mm:ss")
$InviteDate = (Get-LocalTime -UTCTime $InviteOn).toString("yyyy/MM/dd")
If ($debug) {Write-Host "Invitation By $($InviteBy.Title) on $($InviteOn) ($($InviteType)) for $($InviteEmail) - User Found In UIL: $($inUIL) "}
$EmployeeFound = $EmployeeLibraries | WHERE {$.SiteURL -eq $SiteURL -and $_.EmployeeEmail -eq $InviteBy.Email} | Select -First 1
if ($EmployeeFound) {
$ListURL = $EmployeeFound.EmployeeListURL
}
else {
$ListURL = ""
}
$obj = New-Object PSObject
$obj | Add-Member NoteProperty Date $InviteDate
$obj | Add-Member NoteProperty EmployeeSiteURL $SiteURL
$obj | Add-Member NoteProperty EmployeeListURL $ListURL
$obj | Add-Member NoteProperty EmployeeEmail $InviteBy.Email
$obj | Add-Member NoteProperty InvitedOn $InviteOn
$obj | Add-Member NoteProperty InviteType $InviteType
$obj | Add-Member NoteProperty InviteEmail $InviteEmail
$obj | Add-Member NoteProperty inUIL $inUIL
$obj | Add-Member NoteProperty Type $Type
$obj | Add-Member NoteProperty GuestType $GuestType
$InvitesAll += $obj
}
else {
Write-Host "Invitation By $($InviteBy.Title) on $($InviteOn) ($($InviteType)) for $($InviteEmail) - User Found In UIL: $($inUIL) "
}
}
}
The list of all shared links is stored in the $InvitesAll array
Happy Scripting...