SharePoint Online: PowerShell để thay đổi email yêu cầu quyền truy cập cho tất cả các trang web
Yêu cầu: Thay đổi Email yêu cầu quyền truy cập trong SharePoint Online.
PowerShell để thay đổi email yêu cầu quyền truy cập trong SharePoint Online cho tuyển tập trang:
Yêu cầu truy cập cho phép người dùng yêu cầu quyền truy cập vào trang SharePoint hoặc tuyển tập trang. Yêu cầu truy cập được gửi đến địa chỉ email của chủ sở hữu trang web theo mặc định. Tuy nhiên, bạn có thể muốn thay đổi địa chỉ email này thành một địa chỉ email hoặc nhóm khác. Bài viết này sẽ hướng dẫn bạn các bước thay đổi email yêu cầu quyền truy cập trong SharePoint Online.
Hãy đặt email yêu cầu quyền truy cập cho tuyển tập trang SharePoint Online bằng PowerShell:
#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"
Function Set-SPOAccessRequestEmail([String]$SiteURL, [String]$AccessReqEmail)
{
Try{
#Setup the context
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Ctx.Credentials = $Credentials
#Get the Web and Sub Sites
$Web = $Ctx.Web
$Ctx.Load($Web)
$Ctx.Load($web.AllProperties)
$Ctx.Load($Web.Webs)
$Ctx.ExecuteQuery()
#Check if the web has unique permissions
$Web.Retrieve("HasUniqueRoleAssignments")
$Ctx.ExecuteQuery()
If($Web.HasUniqueRoleAssignments -eq $true)
{
#Set Access request Email
$Web.RequestAccessEmail = $AccessReqEmail
$Web.Update()
$Ctx.ExecuteQuery()
Write-Host -f Green "Access Request Email Updated for the Site:" $($SiteURL)
}
Else
{
Write-Host -f Yellow "Site '$($SiteURL)' is inhering Permissions from the Parent"
}
#Iterate through each subsite of the current web
ForEach ($Subweb in $Ctx.Web.Webs)
{
#Call the function recursively
Set-SPOAccessRequestEmail -SiteURL $Subweb.url -AccessReqEmail $AccessReqEmail
}
}
Catch {
write-host -f Red "Error Updating Access Request Email!" $_.Exception.Message
}
}
#Set parameter values
$SiteURL="https://Crescent.sharepoint.com"
$AccessReqEmail="Support@Crescenttech.com"
#Get Credentials to connect
$Cred= Get-Credential
$Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)
#Call the function
Set-SPOAccessRequestEmail -SiteURL $SiteURL -AccessReqEmail $AccessReqEmail
SharePoint Online: Thay đổi địa chỉ email yêu cầu quyền truy cập cho tất cả các trang web trong đối tượng thuê
Hãy để tôi chỉ cho bạn cách sử dụng tập lệnh PowerShell để thay đổi địa chỉ email cho tất cả các trang SharePoint Online. Đây là một cách thuận tiện để quản lý địa chỉ email của tổ chức bạn và giữ chúng nhất quán trên tất cả các trang web.
#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"
#Function to set access request Email of a site/site collection
Function Set-SPOAccessRequestEmail([String]$SiteURL, [String]$AccessReqEmail)
{
Try{
#Setup the context
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Ctx.Credentials = $Credentials
#Get the Web and Sub Sites
$Web = $Ctx.Web
$Ctx.Load($Web)
$Ctx.Load($web.AllProperties)
$Ctx.Load($Web.Webs)
$Ctx.ExecuteQuery()
#Check if the web has unique permissions
$Web.Retrieve("HasUniqueRoleAssignments")
$Ctx.ExecuteQuery()
If($Web.HasUniqueRoleAssignments -eq $true)
{
#Set Access request Email
$Web.RequestAccessEmail = $AccessReqEmail
$Web.Update()
$Ctx.ExecuteQuery()
Write-Host -f Green "Access Request Email Updated for the Site:" $($SiteURL)
}
Else
{
Write-Host -f Yellow "Site '$($SiteURL)' is inhering Permissions from the Parent"
}
#Iterate through each subsite of the current web
ForEach ($Subweb in $Ctx.Web.Webs)
{
#Call the function recursively
Set-SPOAccessRequestEmail -SiteURL $Subweb.url -AccessReqEmail $AccessReqEmail
}
}
Catch {
write-host -f Red "Error Updating Access Request Email!" $_.Exception.Message
}
}
#Change Access Request Settings for All Site collections in the Tenant- Including Modern Team sites and communication sites
Function Change-SPOTenantAccessRequestEmail($AdminSiteURL)
{
#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)
{
Set-SPOAccessRequestEmail -SiteUrl $Site.Url -AccessReqEmail $AccessReqEmail
}
}
#Set global Parameters
$AdminSiteUrl = "https://Crescent-admin.sharepoint.com"
$AccessReqEmail="Support@Crescenttech.com"
#Get Credentials to connect
$Cred= Get-Credential
#Call the function
Change-SPOTenantAccessRequestEmail -AdminSiteURL $AdminSiteUrl
Tập lệnh này thay đổi email yêu cầu truy cập cho tất cả tuyển tập trang trong SharePoint Online. Đây là một bài đăng khác để thay đổi email yêu cầu truy cập hoặc vô hiệu hóa yêu cầu truy cập bằng PowerShell cho một trang SharePoint Online: Cách thay đổi email Yêu cầu truy cập hoặc Tắt yêu cầu truy cập trong SharePoint Online?
