SharePoint Online: Find Who Created a List or Library using PowerShell

Requirement: Find Who has created a list or library in SharePoint Online.

Find Who Created a List or Library in SharePoint Online using PowerShell

Get Who has created a Library in SharePoint Online:

If you want to find out who has created a SharePoint Online list or library: Sorry, There is no way from the SharePoint web user interface! You can’t get the “Created By” value anywhere. The ability to quickly find the creator of a SharePoint Online list or library can be a critical piece of troubleshooting or auditing information. So, PowerShell can help to find this information quickly!

SharePoint Online: Find Who Created a List using PowerShell

We don’t have a List.Author property exposed in CSOM yet. However, We can extract author information from SchemaXML of the list.

#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 call a non-generic method Load
Function Invoke-LoadMethod() 
{
   param([Microsoft.SharePoint.Client.ClientObject]$Object,[string]$PropertyName)
   $ctx = $Object.Context
   $load = [Microsoft.SharePoint.Client.ClientContext].GetMethod("Load")
   $type = $Object.GetType()
   $clientLoad = $load.MakeGenericMethod($type)
   $Parameter = [System.Linq.Expressions.Expression]::Parameter(($type), $type.Name)
   $Expression = [System.Linq.Expressions.Expression]::Lambda([System.Linq.Expressions.Expression]::Convert([System.Linq.Expressions.Expression]::PropertyOrField($Parameter,$PropertyName),[System.Object] ), $($Parameter))
   $ExpressionArray = [System.Array]::CreateInstance($Expression.GetType(), 1)
   $ExpressionArray.SetValue($Expression, 0)
   $clientLoad.Invoke($ctx,@($Object,$ExpressionArray))
}

#Function to get user who created a SharePoint Online List or library
Function Get-SPOListAuthor($SiteURL,$ListName)
{
    Try
    {
        #Get Credentials to connect
        $Cred= Get-Credential

        #Setup the context
        $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
        $Ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)

        #Get the List
        $List=$Ctx.Web.Lists.GetByTitle($ListName)
        $Ctx.Load($List)
        $Ctx.ExecuteQuery()

        #Get List Schema XML
        Invoke-LoadMethod -Object $List -PropertyName "SchemaXML"
        $Ctx.ExecuteQuery()

        #Extract Author from List Schema XML
        $ListSchema =  [xml] $List.SchemaXml
        $AuthorID = $ListSchema.List.Author
        $Author = $Ctx.web.GetUserById($AuthorID)
        $Ctx.Load($Author)
        $Ctx.ExecuteQuery()
        Return $Author
    }
    Catch {
        write-host -f Red "Error:" $_.Exception.Message
    }
}

#Set Parameters
$SiteURL="https://Crescent.sharepoint.com"
$ListName="Documents"

Get-SPOListAuthor -SiteURL $SiteURL -ListName $ListName

Update: The recent version of the CSOM exposes List.Author property through its APIs. So now it is possible to retrieve the author property of a SharePoint Online list directly. E.g.

#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"
 
#Config Parameters
$SiteURL= "https://Crescent.sharepoint.com/sites/Marketing"
$ListName="Projects"
 
#Setup Credentials to connect
$Cred = Get-Credential
 
Try {
    #Setup the context
    $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
    $Ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.UserName,$Cred.Password)
   
    #Get the List Author
    $Web=$Ctx.Web
    $List= $Web.Lists.GetByTitle($ListName)
    $Ctx.Load($List)
    $Ctx.Load($List.Author)
    $Ctx.ExecuteQuery()
      
    Write-host -f Green $List.Author.Email
}
Catch {
    write-host -f Red "Error: " $_.Exception.Message
}

Find Who has Created a Document Library using PnP PowerShell

Need to determine who created a list on your Sharepoint Online site? Here is the PnP PowerShell to check it!

#Parameters
$SiteURL = "https://crescent.sharepoint.com/sites/marketing"
$ListName = "Branding"

#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Interactive

#Get the List
$List = Get-PnPList -Identity $ListName -Includes Author

#Get the author of the list
$List.Author | Select Title, Email

Salaudeen Rajack

Salaudeen Rajack - Information Technology Expert with Two-decades of hands-on experience, specializing in SharePoint, PowerShell, Microsoft 365, and related products. He has held various positions including SharePoint Architect, Administrator, Developer and consultant, has helped many organizations to implement and optimize SharePoint solutions. Known for his deep technical expertise, He's passionate about sharing the knowledge and insights to help others, through the real-world articles!

Leave a Reply

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