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

SharePoint Online: เปลี่ยนเจ้าของกลุ่มโดยใช้ PowerShell


กลุ่ม SharePoint ช่วยให้การดูแลสิทธิ์ง่ายขึ้นโดยการกำหนดชุดผู้ใช้ให้กับกลุ่มและกำหนดสิทธิ์ให้กับพวกเขาผ่านกลุ่ม เมื่อเราสร้างไซต์ กลุ่มเจ้าของเริ่มต้นของไซต์ (เช่น บนไซต์ "การตลาด" จะมีการกำหนด "เจ้าของการตลาด") ให้เป็นเจ้าของกลุ่มสำหรับทุกกลุ่ม หากใครสร้างกลุ่มแบบกำหนดเอง ผู้สร้างจะถูกกำหนดให้เป็นเจ้าของกลุ่ม

จะเปลี่ยนเจ้าของกลุ่มใน SharePoint Online ได้อย่างไร

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

ทำตามขั้นตอนเหล่านี้เพื่อเปลี่ยนเจ้าของกลุ่มใน SharePoint Online:

  1. ไปที่การตั้งค่าไซต์ >> สิทธิ์ของไซต์ >> ผู้คนและกลุ่ม
  2. เลือกกลุ่มที่คุณต้องการเปลี่ยนเจ้าของกลุ่มจากการนำทางด้านซ้าย
  3. จากหน้ากลุ่ม คลิกที่การตั้งค่า >> การตั้งค่ากลุ่ม
  4. ป้อนเจ้าของกลุ่มใหม่ในช่อง "เจ้าของกลุ่ม" กดตกลงเพื่อบันทึกการเปลี่ยนแปลงของคุณ ซึ่งจะเปลี่ยนเจ้าของกลุ่ม SharePoint Online

ตั้งค่าเจ้าของกลุ่มโดยใช้ SharePoint Online Management Shell:

คุณสามารถใช้เชลล์การจัดการแบบออนไลน์ของ SharePoint เพื่อตั้งค่าเจ้าของกลุ่ม SharePoint Online


#Parameters
$AdminSiteURL="https://crescent-admin.sharepoint.com"
$SiteURL="https://crescent.sharepoint.com"
$GroupName="Team Site Members"
$OwnerName="Salaudeen@crescent.com"
 
#Get Credentials to connect to SharePoint Admin Center
$Cred = Get-Credential
 
#Connect to SharePoint Online Admin Center
Connect-SPOService -Url $AdminSiteURL -credential $Cred

#sharepoint online change group owner powershell
Set-SPOSiteGroup -Site $SiteURL -Identity $GroupName -Owner $OwnerName 

PowerShell เพื่อเปลี่ยนเจ้าของกลุ่มใน SharePoint Online:

ต่อไปนี้เป็นวิธีการตั้งค่าเจ้าของกลุ่ม SharePoint Online โดยใช้ PowerShell CSOM


#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"
$GroupName="Team Site Members"
$GroupOwnerName="Salaudeen@crescent.com"
#$GroupOwnerName="Team Site Owners"

#Setup Credentials to connect
$Cred = Get-Credential
$Cred = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.UserName,$Cred.Password)
 
Try {
    #Setup the context
    $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
    $Ctx.Credentials = $Cred
   
    #Get the Group owner - Can be an another Group or User Account
    #$GroupOwner = $Ctx.Web.SiteGroups.GetByName($GroupOwnerName)
    $GroupOwner = $Ctx.Web.EnsureUser($GroupOwnerName)
    
    #Get the Group
    $Group = $Ctx.Web.SiteGroups.GetByName($GroupName)

    #Set the Group Owner
    $Group.Owner = $GroupOwner
    $Group.Update()
    $Ctx.ExecuteQuery()

    Write-host -f Green "Group Owner has been Updated!"
}
Catch {
    write-host -f Red "Error changing Group Owner!" $_.Exception.Message
}

PowerShell เพื่อเปลี่ยนเจ้าของกลุ่มสำหรับกลุ่มทั้งหมดใน SharePoint Online:

มาเปลี่ยนเจ้าของกลุ่มสำหรับทุกกลุ่มในไซต์คอลเลกชัน 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"
$GroupOwnerName="Team Site Owners"

#Setup Credentials to connect
$Cred = Get-Credential
$Cred = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.UserName,$Cred.Password)
 
Try {
    #Setup the context
    $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
    $Ctx.Credentials = $Cred
   
    #Get the Group owner - Can be an another Group or User Account
    $GroupOwner = $Ctx.Web.SiteGroups.GetByName($GroupOwnerName)
    
    #Get All Groups of the Site
    $GroupsColl = $Ctx.web.SiteGroups
    $Ctx.Load($GroupsColl)
    $Ctx.ExecuteQuery()

    #Iterate through each Group - Exclude SharePoint Online System Groups!
    ForEach($Group in $GroupsColl | Where {$_.OwnerTitle -ne "System Account"})
    {
        Write-Host -f Yellow "Changing the Owner of the Group:", $Group.Title

        #sharepoint online powershell set group owner
        $Group.Owner = $GroupOwner
        $Group.Update()
        $Ctx.ExecuteQuery()
    }    

    Write-host -f Green "All Group Owners are Updated!"
}
Catch {
    write-host -f Red "Error changing Group Owners!" $_.Exception.Message
}

นี่คือโพสต์อื่นสำหรับ SharePoint On-premises: จะเปลี่ยนเจ้าของกลุ่มใน SharePoint โดยใช้ PowerShell ได้อย่างไร

SharePoint Online: เปลี่ยนเจ้าของกลุ่มโดยใช้ PnP PowerShell

หากต้องการตั้งค่าเจ้าของกลุ่มสำหรับกลุ่ม SharePoint Online ให้ใช้ PnP PowerShell cmdlet Set-PnPGroup นี้:


#Config Variables
$SiteURL = "https://Crescent.sharepoint.com/Sales"
$GroupName="Sales Portal Members"

#Group owner variable: Can be existing group or user account Email
$GroupOwner = "Sales Portal Owners" #or Salaudeen@Crescent.com
 
#Connect PnP Online
Connect-PnPOnline -Url $SiteURL -Interactive

#Set Group Owner
Set-PnPGroup -Identity $GroupName -Owner $GroupOwner

หากต้องการเปลี่ยนเจ้าของไซต์ใน SharePoint Online ให้ใช้: วิธีการเปลี่ยนเจ้าของไซต์ SharePoint Online โดยใช้ PowerShell

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