Powershell 使用Power Shell遍历SharePoint列表

Powershell 使用Power Shell遍历SharePoint列表,powershell,sharepoint,sharepoint-2010,powershell-2.0,Powershell,Sharepoint,Sharepoint 2010,Powershell 2.0,我有一个名为ListA的SharePoint列表,其中包含以下列 身份证、姓名、公司和地址 该列表包含许多记录,我希望根据公司名称C获取列表中的所有项目,并写入项目名称。如何使用SharePoint Powershell脚本遍历列表?如果您有一个内部SharePoint场,下面是一个简短的片段,可以帮助您了解所需内容: # Define the URL of the site collection you will be querying $siteURL = "http://yourfarm.

我有一个名为ListA的SharePoint列表,其中包含以下列 身份证、姓名、公司和地址


该列表包含许多记录,我希望根据公司名称C获取列表中的所有项目,并写入项目名称。如何使用SharePoint Powershell脚本遍历列表?

如果您有一个内部SharePoint场,下面是一个简短的片段,可以帮助您了解所需内容:

# 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 
和的可能副本