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

วิธีรับวันที่สร้างไซต์ SharePoint โดยใช้ PnP PowerShell


เมื่อเร็วๆ นี้ ลูกค้ารายหนึ่งของฉันขอให้ฉันขอวันที่สร้างไซต์ SharePoint Online ฉันใช้ PnP PowerShell สำหรับสิ่งนี้ ซึ่งใช้งานง่ายและทำงานกับไซต์ SharePoint ในบทช่วยสอนนี้ ฉันจะแสดงวิธีรับวันที่สร้างไซต์ SharePoint โดยใช้ PnP PowerShell

รับวันที่สร้างไซต์ SharePoint โดยใช้ PnP PowerShell

หากคุณมีสิทธิ์เข้าถึงศูนย์การจัดการ SharePoint Online คุณสามารถตรวจสอบวันที่สร้างไซต์ SharePoint ได้จากแท็บไซต์ที่ใช้งานอยู่

มิฉะนั้น PnP PowerShell ก็เป็นอีกตัวเลือกที่ดีที่สุดในการรับวันที่สร้างไซต์ SharePoint

นี่คือสคริปต์ PowerShell ที่สมบูรณ์

# Define the site collection URL
$siteUrl = "https://szg52.sharepoint.com/sites/PowerShellFAQs"

# Connect to SharePoint Online
Connect-PnPOnline -Url $siteUrl -Interactive

# Retrieve the root web of the site collection
$web = Get-PnPWeb -Includes Created

# Retrieve the site collection creation date
$creationDate = $web.Created

# Display the creation date
Write-Host "The site collection was created on:" $creationDate

ฉันรันสคริปต์ PnP PowerShell ด้านบนโดยใช้รหัส VS คุณสามารถดูได้ที่นี่ซึ่งจะแสดงการสร้างไซต์ SharePoint Online

ที่นี่ ฉันใช้ Get-PnPWeb PnP PowerShell cmdlet พร้อมด้วยพารามิเตอร์ -Includes Create เพื่อรับวันที่สร้างรูทเว็บ

หากคุณต้องการใช้โค้ดซ้ำ คุณสามารถสร้างฟังก์ชันดังนี้:

function Get-SPOCreationDate {
    param (
        [Parameter(Mandatory=$true)]
        [string]$SiteUrl
    )

    try {
        # Connect to SharePoint Online
        Connect-PnPOnline -Url $SiteUrl -Interactive

        # Retrieve the root web of the site collection
        $web = Get-PnPWeb -Includes Created

        # Retrieve the site collection creation date
        $creationDate = $web.Created

        # Display the creation date
        Write-Host "The site collection was created on:" $creationDate
    }
    catch {
        Write-Host "An error occurred:" $_.Exception.Message
    }
}

# Example Usage
$siteUrl = "https://szg52.sharepoint.com/sites/PowerShellFAQs"
Get-SPOCreationDate -SiteUrl $siteUrl

ทุกครั้งที่ผู้ใช้ส่ง URL ไซต์ SharePoint วันที่สร้างไซต์จะปรากฏขึ้น

ฉันหวังว่าบทช่วยสอนนี้จะช่วยคุณได้ และคุณได้ทราบวิธีรับวันที่สร้างไซต์ SharePoint Online โดยใช้ PnP PowerShell แล้ว ยังคงมีคำถามโปรดแสดงความคิดเห็นด้านล่าง

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