SharePoint Online:使用 PowerShell 获取列表体验设置
要求:使用 PowerShell 获取 SharePoint Online 中的列表体验设置。
如何获得 SharePoint Online 列表体验?
您是否需要了解 SharePoint Online 网站中应用的列表体验设置?也许您正在解决问题,并且必须确认设置是否按预期配置。或者,您可能对为所有列表和库配置的列表体验感到好奇。无论如何,如果您想获取 SharePoint Online 列表的体验设置,我将向您展示如何审核它们。
要获取 SharePoint Online 中列表或库的列表体验配置,
或者,您还可以使用 PowerShell 脚本获取 SharePoint Online 中的列表体验设置。
使用 PowerShell 检索列表体验:
若要获取 SharePoint Online 中的列表体验设置,您可以使用以下 PowerShell 脚本。
Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameChecking
#Set Parameters for Site URL and List Name
$SiteURL= "https://crescent.sharepoint.com/sites/marketing"
$ListName= "Documents"
#Setup Credentials to connect
$Cred = Get-Credential
Try {
#Setup the context
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.UserName,$Cred.Password)
#Get the List
$List=$Ctx.Web.Lists.GetByTitle($ListName)
$Ctx.Load($List)
$Ctx.ExecuteQuery()
#Get list Experience
Write-host $List.ListExperienceOptions
}
Catch {
write-host -f Red "Error Getting List Experience Settings!" $_.Exception.Message
}
PowerShell 获取 SharePoint Online 网站集中的列表体验设置
我们想要审核 SharePoint Online 网站集中所有列表的列表体验设置。以下是用于将所有列表设置提取到 CSV 文件的 PowerShell 脚本:
#Function to get list experience of all lists in a given web
Function Get-PnPListExperience($Web)
{
Write-host "Processing Web:"$Web.URL -f Yellow
Connect-PnPOnline -Url $Web.URL -Interactive
#Get All Lists from Web and Iterate through - Exclude Hidden and Certain System lists
$ExcludedLists = @("Form Templates", "Site Assets", "Style Library", "Site Pages", "Preservation Hold Library")
$Lists = Get-PnPList | Where {$_.Hidden -eq $False -and $_.Title -notin $ExcludedLists}
ForEach($List in $Lists)
{
#Get List Experience
$Global:ListExperience += New-Object PSObject -Property ([Ordered]@{
'SiteURL' = $Web.URL
'List Title' = $List.Title
'URL' = $List.DefaultViewUrl
'List Experience' = $List.ListExperienceOptions
})
}
}
#Parameters
$SiteURL ="https://crescent.sharepoint.com/sites/operations"
$CSVPath = "C:\Temp\ListExperience.csv"
$Global:ListExperience = @()
#Connect to PnP Online
Connect-PnPOnline -URL $SiteURL -Interactive
#Get All Webs in the site collection and Iterate through
$Webs = Get-PnPSubWeb -Recurse -IncludeRootWeb
ForEach($Web in $Webs)
{
Get-PnPListExperience -Web $Web
}
#Export Data to CSV file
$Global:ListExperience | Sort-Object SiteURL
$Global:ListExperience | Sort-Object SiteURL | Export-csv -Path $CSVPath -NoTypeInformation
报告输出:
结论
总之,通过在 SharePoint Online 中获取列表体验设置,您可以确定列表是使用新体验还是经典体验。通过使用 SharePoint Online UI,您可以导航到列表设置,然后单击“高级设置”,然后您可以在那里找到“列表体验”设置。此外,您还可以使用 PowerShell 脚本检索网站上特定列表或所有列表的列表体验设置。
这是我将列表设置为现代体验的另一篇文章:SharePoint Online:使用 PowerShell 更改列表体验

