Add-PSSnapin Microsoft.SharePoint.PowerShell
# IDS: 7,53
# $ids = 7,53
$webUrl = "http://acme.com/"
$listName = "Long List"
# show all fields
$w = get-spweb $webUrl
$l = $w.Lists[$listName]
[System.Collections.Generic.List[string]]$fldNames = $l.Fields|?{ -not $_.FromBaseType}| % {$_.InternalName}
$ids = $l.Items|%{$_.ID}# |Select-Object -First 15
$arr = [System.Collections.ArrayList]@()
Write-Host -NoNewline "Working "
[int]$cnt = 1
foreach($id in $ids){
$item = $l.GetItemById($id)
$ht = @{}
$ht["ID"] = $item.ID
$ht["Title"] = $item.Title
$ht["Created"] = $item["Created"]
foreach($fldName in $fldNames){
$fld = $l.Fields.GetFieldByInternalName($fldName)
$val = $item[$fld.Id]
$valStr = ""
if($val -ne $null){
$valStr = $val.ToString()
}
$ht[$fld.Title] = $valStr
}
$arr.Add($ht)|Out-Null
$cnt++
if(($cnt % 100) -eq 0) {
Write-Host -NoNewline "."
}
}
Write-Host " done"
Write-Host "Found $($arr.Count) items, stores in variable `$arr"
Comments