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

ค้นหาผู้ที่สร้าง/แก้ไขมุมมอง SharePoint


คุณเคยสงสัยบ้างไหมว่าจะค้นหาผู้ใช้ที่สร้างหรือแก้ไขมุมมอง SharePoint ได้อย่างไร และถูกสร้างขึ้น/แก้ไขเมื่อใด? ไม่มี SharePoint UI ที่จะรับข้อมูลนี้! แต่การใช้โมเดลวัตถุ SharePoint ทำให้เราสามารถดึงข้อมูลเหล่านี้โดยทางโปรแกรมจากคุณสมบัติของวัตถุ SPFile

นี่คือวิธีที่ฉันดึงค่า "สร้างโดย", "สร้างเมื่อ", "แก้ไขโดย" และ "แก้ไขเมื่อ" โดยใช้ PowerShell:


Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Set these two variables accordingly
$WebURL  = "https://sharepoint.crescent.com/"
$ViewURL = "https://sharepoint.crescent.com/LegalDoc/AuthorView.aspx"

 #Get the Web
 $web = Get-SPWeb $WebURL

 #Get the View File
 $ViewFile = $web.GetFile($viewURL)
  
 Write-Host "Created By: " $ViewFile.Author 
 Write-Host "Created on: " $ViewFile.TimeCreated

 Write-Host "Modified By: " $ViewFile.ModifiedBy
 Write-Host "Modified On: " $ViewFile.TimeLastModified

PnP PowerShell เพื่อรับมุมมองรายการที่สร้างโดย/แก้ไขโดยรายละเอียด


#Config Variables
$SiteURL = "https://crescent.sharepoint.com/sites/retail"
$ListName= "Projects"
$ViewName = "All Projects"

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

    #Get the Web
    $Web  = Get-PnPWeb

    #Get the List Views from the list
    $ListView  =  Get-PnPView -List $ListName -Identity $ViewName

    #Get the View File
    $ViewFile = $Web.GetFileByServerRelativeUrl($ListView.ServerRelativeUrl)    
    $Properties = Get-PnPProperty -ClientObject $ViewFile -Property Author, ModifiedBy, TimeCreated, TimeLastModified

    Write-Host "Created By: " $ViewFile.Author.Email
    Write-Host "Created on: " $ViewFile.TimeCreated
    Write-Host "Modified By: " $ViewFile.ModifiedBy.Email
    Write-Host "Modified On: " $ViewFile.TimeLastModified
}
catch {
    write-host "Error: $($_.Exception.Message)" -foregroundcolor Red
}

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