SharePoint Online: รับชื่อไซต์โดยใช้ PowerShell
ความต้องการ: รับชื่อไซต์ SharePoint Online โดยใช้ PowerShell
จะรับชื่อไซต์ใน SharePoint Online ได้อย่างไร
คุณอาจต้องอ้างอิงชื่อเรื่องของไซต์อย่างรวดเร็วในรายงานของคุณที่สร้างจากไซต์ SharePoint Online ในโพสต์บนบล็อกนี้ ฉันจะแสดงวิธีใช้ PowerShell เพื่อรับชื่อเรื่องของไซต์ SharePoint Online
หากต้องการรับชื่อไซต์หรือชื่อไซต์ เพียงเข้าสู่ระบบไซต์ >> คลิกที่การตั้งค่าเกียร์ >> เลือก "ข้อมูลไซต์" >> แล้วคุณจะพบชื่อไซต์!
SharePoint Online: รับชื่อไซต์โดยใช้ PowerShell
ลองใช้สคริปต์ PowerShell เพื่อรับชื่อไซต์ใน SharePoint Online
#Parameters
$AdminSiteURL = "https://crescent-admin.sharepoint.com"
$SiteURL = "https://crescent.sharepoint.com/sites/marketing"
#Connect to SharePoint Online
Connect-SPOService -Url $AdminSiteURL -Credential (Get-Credential)
#Get the Site Collection
$Site = Get-SPOSite -Identity $SiteURL
#Get Site Collection Title
Write-host $Site.Title
PowerShell เพื่อรับชื่อไซต์คอลเลกชัน
นอกจากนี้เรายังสามารถใช้สคริปต์ CSOM PowerShell นี้ในระดับไซต์เพื่อรับชื่อไซต์
#Import PoweShell Module for SharePoint Online
Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameChecking
#Parameter
$SiteUrl = "https://crescent.sharepoint.com/sites/marketing"
#Get 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 web
$Web = $Ctx.Web
$Ctx.Load($Web)
$Ctx.ExecuteQuery()
#Get the site title
Write-host -f Green "Site Title:" $Web.Title
}
catch {
write-host "Error Getting Site Title: $($_.Exception.Message)" -foregroundcolor Red
}
ดึงข้อมูลชื่อไซต์ SharePoint Online โดยใช้ PnP PowerShell
หากคุณกำลังมองหาวิธีรับชื่อไซต์ของคุณใน SharePoint Online โดยใช้ PnP PowerShell ได้เลย:
#Parameters
$SiteURL= "https://crescent.sharepoint.com/sites/marketing"
#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Interactive #-Credential (Get-Credential)
#Get the Root Web
$Web = Get-PnPWeb
#Get the Site Title
Write-host -f Green $Web.Title
โดยสรุป การดึงชื่อไซต์ใน SharePoint Online โดยใช้ PowerShell นั้นเป็นงานที่ตรงไปตรงมาซึ่งสามารถทำได้โดยใช้สคริปต์ไม่กี่บรรทัด ด้วยการใช้ PowerShell ผู้ดูแลระบบ SharePoint สามารถทำงานได้โดยอัตโนมัติ รวมถึงการเรียกข้อมูลไซต์ สคริปต์ที่ให้ไว้ในบทความนี้เป็นตัวอย่างง่ายๆ ของวิธีการเรียกชื่อไซต์ และสามารถปรับให้เหมาะกับความต้องการอื่นๆ ได้
