ค้นหาเว็บไซต์

SharePoint Online: ค้นหาใครเป็นผู้สร้างรายการหรือไลบรารีโดยใช้ PowerShell


ความต้องการ: ค้นหาผู้ที่สร้างรายการหรือไลบรารีใน SharePoint Online

รับผู้ที่สร้างไลบรารีใน SharePoint Online:

ถ้าคุณต้องการค้นหาว่าใครเป็นผู้สร้างรายการหรือไลบรารี SharePoint Online: ขออภัย ไม่มีทางใดจากส่วนติดต่อผู้ใช้บนเว็บของ SharePoint! คุณไม่สามารถรับค่า "สร้างโดย" ได้ทุกที่ ความสามารถในการค้นหาผู้สร้างรายการหรือไลบรารี SharePoint Online ได้อย่างรวดเร็วอาจเป็นส่วนสำคัญของการแก้ไขปัญหาหรือข้อมูลการตรวจสอบ ดังนั้น PowerShell สามารถช่วยค้นหาข้อมูลนี้ได้อย่างรวดเร็ว!

SharePoint Online: ค้นหาใครเป็นผู้สร้างรายการโดยใช้ PowerShell

เรายังไม่มีคุณสมบัติ a List.Author ที่เปิดเผยใน CSOM อย่างไรก็ตาม เราสามารถดึงข้อมูลผู้เขียนจาก SchemaXML ของรายการได้


#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

อัปเดต: CSOM เวอร์ชันล่าสุดเปิดเผยคุณสมบัติ List.Author ผ่าน API ตอนนี้คุณจึงสามารถดึงข้อมูลคุณสมบัติผู้เขียนของรายการ SharePoint Online ได้โดยตรง เช่น.


#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
}

ค้นหาใครเป็นผู้สร้างไลบรารีเอกสารโดยใช้ PnP PowerShell

ต้องการทราบว่าใครเป็นผู้สร้างรายการบนไซต์ Sharepoint Online ของคุณ? นี่คือ PnP PowerShell เพื่อตรวจสอบ!


#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

บทความที่เกี่ยวข้อง