当前位置:网站首页 > 更多 > 玩电脑 > 正文

[玩转系统] SharePoint Online:使用 PowerShell 配置访问请求设置

作者:精品下载站 日期:2024-12-14 21:01:59 浏览:12 分类:玩电脑

SharePoint Online:使用 PowerShell 配置访问请求设置


SharePoint Online 中的访问请求设置
SharePoint Online 中的访问请求功能允许人们请求访问他们无权访问的内容。它还允许网站成员向没有权限的用户发送邀请。发送邀请后,网站所有者应从“网站设置”>>“访问请求和邀请”中批准邀请。如果您在网站集级别更改这些设置,则新的子网站不会继承。

如何设置SharePoint Online访问请求电子邮件?

要在 SharePoint Online 中配置访问请求电子邮件设置,请转到:

  1. 站点设置>>站点权限>>访问请求设置。
  2. 这将带您进入 SharePoint Online 访问请求页面 >> 更新访问请求电子邮件,然后单击“确定”保存更改。

    [玩转系统] SharePoint Online:使用 PowerShell 配置访问请求设置

同样,在群组连接的站点上,您可以通过转到设置>>站点权限>>单击“更改成员共享方式”>>打开“允许访问请求”并配置谁将接收访问请求来设置访问请求对于该网站。

[玩转系统] SharePoint Online:使用 PowerShell 配置访问请求设置

请注意,必须在每个网站级别配置 SharePoint Online 访问请求电子邮件网站设置。让我们看看如何使用 SharePoint Online PowerShell 设置访问请求电子邮件。

如果站点继承了其父站点的权限,则访问请求设置也会继承!换句话说,您只能为具有独特权限的网站设置访问请求设置!

使用 PowerShell 设置 SharePoint Online 访问请求设置

使用此 PowerShell 脚本更新 SharePoint Online 访问请求电子邮件。


#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
  
#Set Variables for Site URL
$SiteURL= "https://crescent.sharepoint.com/sites/sales/"
$AccessReqEmail="[email protected]"

#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 current settings
    $Web = $Ctx.Web
    $Ctx.Load($web.AllProperties)
    $web.RequestAccessEmail
    $Ctx.ExecuteQuery()

    #sharepoint online powershell set access request email
    $Web.RequestAccessEmail =$AccessReqEmail
    #Member settings
    $Web.MembersCanShare = $True
    $web.AssociatedMemberGroup.AllowMembersEditMembership = $True
    $web.AssociatedMemberGroup.Update()

    $Web.Update()
    $Ctx.ExecuteQuery()
}
Catch {
    write-host -f Red "Error configuring Access request settings!" $_.Exception.Message
}

这将使用 PowerShell 设置 SharePoint Online 访问请求设置。

使用 PowerShell 在 SharePoint Online 中禁用访问请求:

要禁用访问请求,只需清除电子邮件值即可!


#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
  
#Set Variables for Site URL
$SiteURL= "https://crescent.sharepoint.com/sites/sales/"

#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

    #sharepoint online disable access request powershell
    $Web = $Ctx.Web
    $Web.RequestAccessEmail = [string]::Empty
    $Web.MembersCanShare = $False    
    $web.AssociatedMemberGroup.AllowMembersEditMembership = $False
    $web.AssociatedMemberGroup.Update()
    $Web.Update()
    $Ctx.ExecuteQuery()
}
Catch {
    write-host -f Red "Error disabling Access request settings!" $_.Exception.Message
}

若要更改网站集或租户中所有网站的访问请求电子邮件,请使用:SharePoint Online:用于更改所有网站的访问请求电子邮件的 PowerShell

SharePoint Online:使用 PnP PowerShell 禁用访问请求


#Set Variables
$SiteURL = "https://crescent.sharepoint.com/sites/Marketing"

#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Credentials (Get-Credential)

#Get the Web
$Web = Get-PnPWeb

#sharepoint online powershell disable access requests
$Web.RequestAccessEmail = [string]::Empty
$Web.SetUseAccessRequestDefaultAndUpdate($False)
$Web.Update()
$Web.Context.ExecuteQuery()

此 PowerShell 脚本会清除访问请求电子邮件和组设置!同样,要禁用租户中所有网站的访问请求,请使用:SharePoint Online:使用 PowerShell 禁用所有网站的访问请求

使用 PnP PowerShell 启用对网站所有者组的访问请求:

要设置对网站所有者的访问请求,请使用:


#Set Variables
$SiteURL = "https://crescent.sharepoint.com/sites/Marketing"

#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Credentials (Get-Credential)

#Get the Web
$Web = Get-PnPWeb

#Enable Access Request for the site to the Owners Group
$Web.SetUseAccessRequestDefaultAndUpdate($True)
$Web.Update()
$Web.Context.ExecuteQuery()

同样,要在访问请求中设置电子邮件,请使用 PnP PowerShell cmdlet Set-PnPRequestAccessEmails:


Connect-PnPOnline -Url https://crescent.sharepoint.com/sites/marketing -Interactive

#Update Access Request Email
Set-PnPRequestAccessEmails -Emails @("[email protected]", "[email protected]")

[玩转系统] SharePoint Online:使用 PowerShell 配置访问请求设置

要更改 SharePoint Online 中的访问请求电子邮件,请使用以下命令:


#Enable Access Request for the site to a Email ID
$Web.RequestAccessEmail = "[email protected]"
$Web.SetUseAccessRequestDefaultAndUpdate($False)
$Web.Update()
$Web.Context.ExecuteQuery()

最后但并非最不重要的一点是:SharePoint Online 中是否缺少访问请求和邀请?嗯,那是因为 - 访问请求设置被禁用!

您需要 登录账户 后才能发表评论

取消回复欢迎 发表评论:

关灯