Hi there,
Does anyone know where I could find an example of how to read data from a document library in Office 365 sharepoint into a CSV file.
I can get the id of each record but I am not sure how to get the other fields I have created.
Thanks
Mark
Here is some of my code:
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($webUrl)
$ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password)
$web = $ctx.Web
$lists = $web.Lists.GetByTitle(‘hireman_documents’)
$ctx.Load($lists)
$query = [Microsoft.SharePoint.Client.CamlQuery]::CreateAllItemsQuery(10000)
$items = $lists.GetItems( $query )
$ctx.load($items)
$ctx.ExecuteQuery();
$count = $items.Count – 1
for($intIndex = $count; $intIndex -gt -1; $intIndex–)
{
   Write-Host $intIndex $items[$intIndex].Id      Â
}
Hi Nico,
The scripts pointed me in the right direction. Thanks alot.
Part of the problem was the custom column had a space and I need to use Job_x0020_Number instead of Job Number.
I just need to use the export-csv to get the fields into a csv file but that shouldn’t be hard.
If you ever want to learn qlikview \ qlik sense let me know, you can contact me through my site http://www.techstuffy.com
All the best
Mark
Here is the script I ended up with that works with Office 365 Sharepoint :
$loadInfo1 = [System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.SharePoint.Client”)
$loadInfo2 = [System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.SharePoint.Client.Runtime”)
$webUrl = “https://your site”
$username = “your username”
$password = “your password” | ConvertTo-SecureString -AsPlainText -Force
$sourceListName = “hireman_documents”
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($webUrl)
$ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password)
$web = $ctx.Web
$list = $web.Lists.GetByTitle(‘your library’)
$query = New-Object Microsoft.SharePoint.Client.CamlQuery
         Â
$items = $list.GetItems($query)
$ctx.Load($list)
$ctx.Load($items);
$ctx.ExecuteQuery()
Write-Host $list.Title $list.ItemCount
Write-Host *************************
$items |% {Â Â Â Â Â Â Â Â Â Write-host “$($_[“Job_x0020_Number”]), $($_[“FileLeafRef”]) “}
Hi,
There is some limitation in the SharePoint Online Management Shell, different cmdlets are available, but I’m not sure if all functionality is included. If I have time somewhere this week I can try to figure out if I can make it work. If you have questions, just post them and I’ll try to get back to you asap.
Hi Nic,
I command I don’t have is Get-SPWeb, I think this might be because my sharepoint installation is not on premise.
I do have the sharepoint online management shell installed.
Mark
Hi Mark,
Sorry, I didn’t read your question right, you’re talking about Office365. That works a little differently right there. If I have any info on this, I’ll let you know.
Hi Nico,
Thanks for the quick reply.
I’m looking to get the data from the columns I have added to the document library as well as the name of each file. I am using Office 365 Sharepoint.
I’ll have a look at the links and see how I get on.
Thanks
Mark