SharePoint Online: PowerShell เพื่อรับผู้ดูแลไซต์คอลเลกชัน
ข้อกำหนด: SharePoint Online PowerShell เพื่อแสดงรายการผู้ดูแลระบบคอลเลกชันไซต์ทั้งหมด
ผู้ดูแลระบบคอลเลกชันไซต์ SharePoint Online มีสิทธิ์ควบคุมไซต์คอลเลกชันทั้งหมดได้อย่างสมบูรณ์ รวมถึงไซต์ระดับบนสุด ไซต์ย่อย รายการทั้งหมด และไลบรารีในไซต์คอลเลกชัน ไซต์คอลเลกชัน SharePoint แต่ละไซต์สามารถมีผู้ดูแลไซต์คอลเลกชันของตัวเองได้ โดยทั่วไปแล้วจะได้รับมอบหมายในช่วงเวลาของไซต์คอลเลกชันที่สร้างโดยผู้ดูแลระบบ SharePoint Online ผ่านทางไซต์ศูนย์การจัดการ SharePoint Online ในฐานะเจ้าของไซต์หลักและผู้ดูแลระบบไซต์คอลเลกชัน ผู้ดูแลไซต์คอลเลกชันเพิ่มเติมใดๆ สามารถเพิ่ม/เอาออกได้ผ่านทางหน้าการตั้งค่าไซต์
วิธีรับผู้ดูแลไซต์คอลเลกชันทั้งหมดจากศูนย์การจัดการ SharePoint
ฉันจะค้นหาผู้ดูแลคอลเลกชันใน SharePoint Online ได้อย่างไร หากต้องการรับผู้ดูแลไซต์คอลเลกชันทั้งหมด ให้เข้าสู่ระบบ SharePoint Admin Center จากเบราว์เซอร์ที่คุณชื่นชอบ เช่น Microsoft Edge หรือ Google Chrome >> ขยาย "ไซต์" >> ไซต์ที่ใช้งานอยู่ >> เลือกไซต์จากรายการ >> คลิกที่ "สิทธิ์" จากนั้น เลือก “จัดการผู้ดูแลระบบ”
ผู้ดูแลไซต์คอลเลกชันมีสิทธิ์การเข้าถึงเช่นเดียวกับเจ้าของไซต์ SharePoint หลัก แต่ข้อแตกต่างเพียงอย่างเดียวคือการแจ้งเตือนทางอีเมล! ผู้ดูแลไซต์คอลเลกชันหลักจะได้รับการแจ้งเตือนทางอีเมล เช่น อีเมลคำเตือนขีดจำกัดที่เก็บข้อมูลของไซต์คอลเลกชัน
จะรับผู้ดูแลไซต์คอลเลกชันใน SharePoint Online จากการตั้งค่าไซต์ได้อย่างไร
ถ้าคุณต้องการให้ผู้ดูแลไซต์คอลเลกชันทั้งหมดของไซต์ SharePoint Online ให้ทำดังต่อไปนี้:
- คลิกที่ไอคอนการตั้งค่าเกียร์และเลือกการตั้งค่าไซต์
- ในหน้าการตั้งค่าไซต์ คลิกลิงก์ "ผู้ดูแลไซต์คอลเลกชัน" ใต้กลุ่ม "ผู้ใช้และการอนุญาต" (กดทางลัด URL นี้ในเบราว์เซอร์: /_layouts/15/mngsiteadmin.aspx)
เพจนี้จะแสดงรายชื่อผู้ดูแลไซต์คอลเลกชันบนไซต์คอลเลกชันนั้น ๆ
บนไซต์ที่เชื่อมต่อกับกลุ่มสมัยใหม่ ผู้ดูแลไซต์คอลเลกชันจะอยู่ภายใต้การตั้งค่า >> สิทธิ์ของไซต์ >> การตั้งค่าสิทธิ์ขั้นสูง
ตอนนี้ มาใช้สคริปต์ PowerShell เพื่อรับผู้ดูแลไซต์คอลเลกชันใน SharePoint Online
รับผู้ดูแลไซต์คอลเลกชันหลัก - เจ้าของที่ใช้ PowerShell
ต่อไปนี้เป็นวิธีใช้สคริปต์ PowerShell เพื่อรับผู้ดูแลไซต์คอลเลกชันใน SharePoint Online:
#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.SharePoint.Client.Runtime.dll"
Add-Type -Path "C:\Program Files\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.Online.SharePoint.Client.Tenant.dll"
#Get Primary Owners of All Site collections from the Tenant
Function Get-SPOPrimarySiteOwners($AdminSiteURL, $Cred)
{
#Setup credentials to connect
$Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)
#Setup the context
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($AdminSiteURL)
$Ctx.Credentials = $Credentials
#Get the tenant object
$Tenant = New-Object Microsoft.Online.SharePoint.TenantAdministration.Tenant($ctx)
#Get All Site Collections
$SiteCollections=$Tenant.GetSitePropertiesFromSharePoint(0,$true)
$Ctx.Load($SiteCollections)
$Ctx.ExecuteQuery()
#Iterate through Each site collection
ForEach($Site in $SiteCollections)
{
#Get the Site Collection and Audit Objects
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($Site.URL)
$Ctx.Credentials = $Credentials
#Get the Site collection
$SiteCollection = $Ctx.Site
$Ctx.Load($SiteCollection)
$Ctx.ExecuteQuery()
#Get Site Owner
$Owner = $SiteCollection.Owner
$Ctx.Load($Owner)
$Ctx.ExecuteQuery()
#Output Primary Site owner Details
$SiteCollection | Select URL, @{Name="Owner Name";Expression={$_.Owner.Title}}, @{Name="Owner Email";Expression={$_.Owner.Email}}
}
}
#Set Parameters
$AdminSiteUrl = "https://Crescent-admin.sharepoint.com/"
$Cred= Get-Credential
Get-SPOPrimarySiteOwners -AdminSiteURL $AdminSiteUrl -Cred $Cred
ตรวจสอบให้แน่ใจว่าคุณได้ติดตั้ง CSOM SDK หรือ SharePoint Online PowerShell Module ในเครื่องของคุณก่อนที่จะรันสคริปต์นี้ คุณสามารถใช้ Windows PowerShell ISE เพื่อเรียกใช้สคริปต์ได้ ได้รับผู้ดูแลไซต์คอลเลกชันหลักโดยใช้ PowerShell ใน SharePoint Online
SharePoint Online: PowerShell เพื่อรับผู้ดูแลไซต์คอลเลกชัน
คุณสามารถใช้ PowerShell cmdlet Get-SPOUser พร้อมกับตัวกรองคุณสมบัติ IsSiteAdmin เพื่อรับรายชื่อผู้ดูแลไซต์คอลเลกชันของไซต์คอลเลกชันที่กำหนด สิ่งนี้จะทำให้คุณได้รับทั้งเจ้าของไซต์หลักและผู้ดูแลไซต์คอลเลกชัน
#Variables for processing
$AdminURL = "https://Crescent-admin.sharepoint.com/"
$AdminName = "SPAdmin@Crescent.com"
$SiteCollURL="https://Crescent.sharepoint.com/sites/sales"
#User Names Password to connect
$Password = Read-host -assecurestring "Enter Password for $AdminName"
$Credential = new-object -typename System.Management.Automation.PSCredential -argumentlist $AdminName, $Password
#Connect to SharePoint Online
Connect-SPOService -url $AdminURL -credential $Credential
#Get the Site colection
$SiteColl = Get-SPOSite $SiteCollURL
#sharepoint online powershell get all site collection admins
$SiteAdmins = Get-SPOUser -Site $SiteCollURL -Limit ALL | Where { $_.IsSiteAdmin -eq $True}
foreach($Admin in $SiteAdmins)
{
Write-host $Admin.LoginName
}
PowerShell เพื่อรับผู้ดูแลไซต์คอลเลกชันของไซต์คอลเลกชันทั้งหมดใน SharePoint Online
มาเพิ่มการจัดการข้อผิดพลาดและรับผู้ดูแลไซต์คอลเลกชันจากไซต์คอลเลกชันทั้งหมด
#Variables for processing
$AdminURL = "https://Crescent-admin.sharepoint.com"
$AdminName = "spadmin@Crescent.com"
#User Names Password to connect
$Password = Read-host -assecurestring "Enter Password for $AdminName"
$Credential = new-object -typename System.Management.Automation.PSCredential -argumentlist $AdminName, $Password
Try {
#Connect to SharePoint Online
Connect-SPOService -url $AdminURL -credential $Credential
#Get all Site colections
$Sites = Get-SPOSite -Limit ALL
Foreach ($Site in $Sites)
{
Write-host $Site.URL
#Get all Site Collection Administrators
$SiteAdmins = Get-SPOUser -Site $Site.Url -Limit ALL | Where { $_.IsSiteAdmin -eq $True}
foreach($Admin in $SiteAdmins)
{
Write-host $Admin.LoginName
}
}
}
catch {
write-host "Error: $($_.Exception.Message)" -foregroundcolor Red
}
รับผู้ดูแลไซต์คอลเลกชันทั้งหมดโดยใช้ PnP PowerShell ใน SharePoint Online
ด้วย PnP PowerShell ผู้ดูแลระบบคอลเลกชันไซต์สามารถเรียกข้อมูลได้ด้วย Get-PnPSiteCollectionAdmin cmdlet นี่คือ SharePoint Online PowerShell สำหรับผู้ดูแลไซต์คอลเลกชันทั้งหมด:
#Set Variables
$SiteURL = "https://crescent.sharepoint.com/sites/Marketing"
#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Credentials (Get-Credential)
#Get Site Collection Administrators
Get-PnPSiteCollectionAdmin
สคริปต์ PnP PowerShell นี้รับผู้ดูแลไซต์คอลเลกชันทั้งหมดของไซต์คอลเลกชันที่กำหนด เมื่อต้องการขอรับผู้ดูแลไซต์คอลเลกชันของไซต์ทั้งหมดในผู้เช่า ใช้ดังต่อไปนี้:
#Set Variables
$SiteURL = "https://crescent.sharepoint.com"
#Get Credentials to connect
$Cred = Get-Credential
#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Credentials $Cred
#Get All Site collections
$SitesCollection = Get-PnPTenantSite
#Loop through each site collection
ForEach($Site in $SitesCollection)
{
Write-host -F Green "Site Collection Administrators of site: " $Site.Url
Connect-PnPOnline -Url $Site.Url -Credentials $Cred
#Get Site Collection administrators of the site
Get-PnPSiteCollectionAdmin
}
รับผู้ดูแลไซต์คอลเลกชันจากไซต์ที่เชื่อมต่อแบบกลุ่ม
หากไซต์เชื่อมต่อกับกลุ่ม คุณจะเห็นเพียง "เจ้าของกลุ่ม" ในเอาต์พุตสคริปต์ด้านบน ต่อไปนี้เป็นวิธีขยายและรับเจ้าของจากกลุ่ม:
#Set Variables
$AdminSiteURL = "https://crescent-admin.sharepoint.com"
#Connect to Admin Center
Connect-PnPOnline -Url $AdminSiteURL -Interactive
#Get All Site collections - Exclude: Seach Center, Mysite Host, App Catalog, Redirect, Content Type Hub, eDiscovery and Bot Sites
$SiteCollections = Get-PnPTenantSite | Where -Property Template -NotIn ("SRCHCEN#0", "REDIRECTSITE#0", "SPSMSITEHOST#0", "APPCATALOG#0", "POINTPUBLISHINGHUB#0", "EDISC#0", "STS#-1")
#Loop through each site collection
ForEach($Site in $SiteCollections)
{
Write-host -F Yellow "Getting Site Collection Administrators of the site: " $Site.Url
Connect-PnPOnline -Url $Site.Url -Interactive
#Get Site Collection Administrators
$SiteAdminstrators = @()
Get-PnPSiteCollectionAdmin -PipelineVariable Admin | ForEach-Object {
If($_.PrincipalType -eq "SecurityGroup")
{
#Get Members of the Group
$Group = Get-PnPMicrosoft365Group -IncludeOwners | Where {$_.Mail -eq $Admin.Email}
$Group.Owners | Select Email | ForEach-Object {
$SiteAdminstrators += $_.Email
}
}
Else
{
$SiteAdminstrators += $Admin.Email
}
}
#Get Site Collection Administrators of the Site
$SiteAdminstrators | select -Unique
}
หากคุณต้องการส่งออกผู้ดูแลระบบคอลเลกชันไซต์ทั้งหมดเป็นไฟล์ CSV โปรดดู: ส่งออกผู้ดูแลระบบคอลเลกชันไซต์ SharePoint Online เป็น CSV
คำถามที่พบบ่อย:
ฉันจะเพิ่มการดูแลไซต์คอลเลกชันใน SharePoint ออนไลน์โดยใช้ PowerShell ได้อย่างไร
ในการเพิ่มผู้ดูแลระบบคอลเลกชันไซต์ SharePoint ให้ใช้: เช่น “Set-SPOUser -site $SiteURL -LoginName 'UPN of the user' -IsSiteCollectionAdmin $True” ใน SharePoint Online Management Shell หรือ Add-PnPSiteCollectionAdmin/Set-PnPTenantSite cmdlets โดยใช้ PnP PowerShell . คุณยังสามารถใช้โมเดลออบเจ็กต์ฝั่งไคลเอ็นต์เพื่อตั้งค่าคุณสมบัติ "IsSiteAdmin" ของผู้ใช้เพื่อตั้งค่าผู้ดูแลระบบไซต์คอลเลกชัน
ข้อมูลเพิ่มเติม: SharePoint Online PowerShell เพื่อเพิ่มผู้ดูแลไซต์คอลเลกชัน
ฉันจะลบผู้ดูแลระบบคอลเลกชันใน SharePoint Online ได้อย่างไร
คุณสามารถใช้ศูนย์การจัดการ SharePoint Online หน้าการตั้งค่าไซต์ หรือสคริปต์ PowerShell เพื่อลบผู้ดูแลไซต์คอลเลกชันออกจากไซต์ SharePoint Online
ข้อมูลเพิ่มเติม: เอาผู้ดูแลไซต์คอลเลกชันใน SharePoint Online
ฉันจะเปลี่ยนผู้ดูแลระบบหลักใน SharePoint Online ได้อย่างไร
คุณสามารถเปลี่ยนเจ้าของไซต์ผ่านทางศูนย์การจัดการ SharePoint โดยเลือกไซต์คอลเลกชัน คลิกที่ "สิทธิ์" จากนั้น "จัดการผู้ดูแลระบบ" บนแผง “จัดการผู้ดูแลระบบ ” คุณสามารถเปลี่ยนผู้ดูแลไซต์คอลเลกชันหลัก - เจ้าของไซต์โดยการตั้งค่าให้เป็น “ผู้ดูแลระบบหลัก”
ข้อมูลเพิ่มเติม: วิธีเปลี่ยนเจ้าของไซต์ (ผู้ดูแลระบบหลัก) ใน SharePoint Online

