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

[玩转系统] 使用 PowerShell 获取 SharePoint 中的列表字段

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

使用 PowerShell 获取 SharePoint 中的列表字段


要求:使用 PowerShell 从 SharePoint 列表中获取所有字段。

用于获取所有列表字段、内部名称和字段类型的 PowerShell 脚本:

让我们使用 PowerShell 获取 SharePoint 列表列的内部名称。


Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Configuration Parameters
$SiteURL="https://intranet.crescent.com/"
$ListName= "Quick Links"

#Get the List
$List = (Get-SPWeb $SiteURL).Lists.TryGetList($ListName)

Write-Host "Field Name | Internal Name | Type"
Write-Host "------------------------------------"

#Loop through each field in the list and get the Field Title, Internal Name and Type
ForEach ($Field in $List.Fields)
{
    Write-Host $Field.Title"|"$Field.internalName"|"$Field.Type
}  

此 PowerShell 脚本从给定的 SharePoint 列表中获取所有列名称、内部名称和列类型!

[玩转系统] 使用 PowerShell 获取 SharePoint 中的列表字段

PowerShell 将列表字段导出到 CSV 文件:

让我们使用 PowerShell 将列表的所有字段导出到 CSV 文件中。


Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Configuration Parameters
$SiteURL="https://intranet.crescent.com/"
$ListName= "Projects"
$CSVPath="C:\Temp\Fields.csv"

#Get the Web and List
$Web = Get-SPWeb $SiteURL
$List = $Web.Lists.TryGetList($ListName)

#Export List Fiels to CSV file
$List.Fields | select Title, InternalName | Export-Csv -path $CSVPath -NoTypeInformation

要获取 SharePoint Online 中的列表字段,请参阅:SharePoint Online:使用 PowerShell 获取列表字段

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

取消回复欢迎 发表评论:

关灯