SharePoint Online: Find Who Created a List or Library using PowerShell
Requirement: Find Who has created a list or library in SharePoint Online.
Get Who 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 SharePoint web user Interface! You can't get "Created By" value anywhere. But PowerShell can help!
SharePoint Online: Find Who Created a List using PowerShell
We don't have List.Author property exposed in CSOM. However, We can extract author information from SchemaXML of the list.
Get Who 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 SharePoint web user Interface! You can't get "Created By" value anywhere. But PowerShell can help!
SharePoint Online: Find Who Created a List using PowerShell
We don't have List.Author property exposed in CSOM. 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://crescenttech.sharepoint.com" $ListName="Documents" Get-SPOListAuthor -SiteURL $SiteURL -ListName $ListName
No comments:
Please Login and comment to get your questions answered!