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

[玩转系统] SharePoint Online:使用 PowerShell 获取所有功能

作者:精品下载站 日期:2024-12-14 14:57:25 浏览:13 分类:玩电脑

SharePoint Online:使用 PowerShell 获取所有功能


要求:用于列出功能的 SharePoint Online PowerShell。

如何获取 SharePoint Online 中的网站功能?

Microsoft SharePoint Online 是一个出色的平台,提供了许多特性和功能。在某些情况下,您可能需要查看站点上所有可用功能的列表。在这篇博文中,我将向您展示如何使用 PowerShell 获取 SharePoint Online 中可用的所有功能。

要获取 SharePoint Online 中的功能,请转到“站点设置”>> 单击“站点功能”以获取 Web 范围的功能。同样,您可以单击“网站集功能”来获取网站集功能列表。

[玩转系统] SharePoint Online:使用 PowerShell 获取所有功能

SharePoint Online:获取网站集功能 PowerShell

让我们使用 PowerShell 列出 SharePoint Online 网站功能。此 PowerShell 脚本获取给定 URL 的站点和 Web 范围中存在的所有功能。


#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"

#Variables
$SiteURL="https://Crescent.sharepoint.com"

#Setup Credentials to connect
$Cred= Get-Credential
$Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)

#Setup the context
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Ctx.Credentials = $Credentials

#Get Site Collection Features
$SiteCollFeatures = $Ctx.Site.Features
$Ctx.Load($SiteCollFeatures)
$Ctx.ExecuteQuery()            

#Loop through each feature and get feature data
Write-host "Site Collection Features:"
ForEach($Feature in $SiteCollFeatures)
{
    $Feature.Retrieve("DisplayName")
    $Ctx.Load($Feature)
    $Ctx.ExecuteQuery()
    $Feature | Select DisplayName, DefinitionId
}

SharePoint Online:使用 PowerShell 获取功能

以下是用于在 Web 范围内获取 SharePoint Online 功能的 PowerShell。


#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"

#Variables
$SiteURL="https://Crescent.sharepoint.com"

#Setup Credentials to connect
$Cred= Get-Credential
$Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)

#Setup the context
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Ctx.Credentials = $Credentials

#Get Web Level Features
Write-host "`nWeb Scoped Features:"
#Get web Features
$WebFeatures = $Ctx.Web.Features
$Ctx.Load($WebFeatures)
$Ctx.ExecuteQuery()

#Loop through each feature and get feature data
ForEach($Feature in $WebFeatures)
{
    $Feature.Retrieve("DisplayName")
    $Ctx.Load($Feature)
    $Ctx.ExecuteQuery()
    $Feature | Select DisplayName, DefinitionId
}

用于在 SharePoint Online 中获取网站集功能的 PnP PowerShell:

若要从 SharePoint Online 网站获取功能,请使用 Get-PnPFeature cmdlet。如果您想按特定范围过滤功能列表,可以使用“Scope”参数。例如,要获取站点范围内的所有功能的列表,请运行以下脚本:


#Config Variable
$SiteURL = "https://Crescent.sharepoint.com/Sites/Marketing"

#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Interactive

#Get Site Collection Features
Get-PnPFeature -Scope Site | Select DisplayName, DefinitionID

同样,您可以检索 Web 范围的功能,如下所示:


#Config Variable
$SiteURL = "https://Crescent.sharepoint.com/Sites/Marketing"

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

#Get Web Features
Get-PnPFeature -Scope Web | Select DisplayName, DefinitionID

相关文章:

  • 使用 PowerShell 激活 SharePoint Online 功能:SharePoint Online 使用 PowerShell 激活发布功能
  • 停用 SharePoint Online 功能 PowerShell:用于禁用功能的 SharePoint Online PowerShell

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

取消回复欢迎 发表评论:

关灯