Monday, November 30, 2015

Export the Page Library/list Items to CSV using PowerShell


Export the Page Library/list Items to CSV using PowerShell


$web = Get-SPWeb -identity "http://mydomain.com/site/"

#Get the Target List
$list = $web.Lists["Pages"]

#Array to Hold Result - PSObjects
$ListItemCollection = @()

$list.Items  | foreach {
$ExportItem = New-Object PSObject
$ExportItem | Add-Member -MemberType NoteProperty -name Title -value $_["Title"]
$ExportItem | Add-Member -MemberType NoteProperty -Name Name -value $_["Name"]
$ExportItem | Add-Member -MemberType NoteProperty -name Created -value $_["Created"]
$ExportItem | Add-Member -MemberType NoteProperty -name ExternalURL -value $_["Byline"]


#Add the object with property to an Array
$ListItemCollection += $ExportItem
}
#Export the result Array to CSV file
$ListItemCollection | Export-CSV e:\pub\ExportFile.csv ~ -NoTypeInformation                       

#Dispose the web Object
$web.Dispose()

No comments:

Post a Comment