【发布时间】:2017-01-17 06:37:49
【问题描述】:
我有一个名为“ListA”的 SharePoint 列表,其中包含以下列 身份证、姓名、公司和地址
列表包含许多记录,我想根据公司名称“C”获取列表中的所有项目并写入项目名称。如何使用 SharePoint Powershell 脚本遍历列表?
【问题讨论】:
标签: powershell sharepoint sharepoint-2010 powershell-2.0
我有一个名为“ListA”的 SharePoint 列表,其中包含以下列 身份证、姓名、公司和地址
列表包含许多记录,我想根据公司名称“C”获取列表中的所有项目并写入项目名称。如何使用 SharePoint Powershell 脚本遍历列表?
【问题讨论】:
标签: powershell sharepoint sharepoint-2010 powershell-2.0
如果您有一个本地 SharePoint 场,这里有一个简短的 sn-p,应该可以为您提供所需的内容:
# Define the URL of the site collection you will be querying
$siteURL = "http://yourfarm.domain.com/"
# Define the Title of the web that hosts your list
$webTitle = "TheWebTheListIsOn"
# Define the Title of the List that you will be querying
$listTitle = "ListA"
# Create a unique file name for the csv export
$date = Get-Date -UFormat "%Y%m%d"
$csvFilePath = "$($webTitle.Replace(' ',''))_$($listName.Replace(' ',''))_$($date).csv"
# Query the list based on a criteria and export to csv
$items = Get-SPSite -Identity $siteURL `
| select -ExpandProperty AllWebs `
| where { $_.Title -eq $webTitle } `
| select -ExpandProperty Lists `
| where { $_.Title -eq $listTitle } `
| select -ExpandProperty Items `
| where { $_['Company'] -like "C*" } `
| select Id, Name, Company, Address `
| Export-Csv -NoTypeInformation -Path $csvFilePath
【讨论】: