title: Access all the fields in a Lists using powershell,SharePoint and csom
body: <p>I am trying to retrieve all the items in my list and for each item display the Title of the item,ID and created fields on the console. Also when I do a <code>get-member</code> on the Items collection I don't see all the fields in the list (not even the title field, only the ID and some other fields that I don't believe are used very much like <code>DisplayName</code>)</p>
  
  <p>I would have thought that the <code>caml</code> query will only select the fields to show, but none of the items I specified on my <code>Caml</code> query are showing on <code>get-Member</code></p>
  
  <p>Please can anybody help spot what I may be doing wrong</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>Add-Type –Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"
  Add-Type –Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
  
  Function Get-SPOContext([string]$Url,[string]$UserName,$Password)
  {
      #$SecurePassword = $Password | ConvertTo-SecureString -AsPlainText -Force
      $context = New-Object Microsoft.SharePoint.Client.ClientContext($Url)
      $context.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserName, $Password)
      return $context
  }
  
  Function Get-ListItems([Microsoft.SharePoint.Client.ClientContext]$Context, [String]$ListTitle) {
      $list = $Context.Web.Lists.GetByTitle($listTitle)
      $qry = [Microsoft.SharePoint.Client.CamlQuery]::CreateAllItemsQuery(13,'ID','Created','Modified','Title')
      $items = $list.GetItems($qry)
      $Context.Load($items)
      $Context.ExecuteQuery()
      return $items 
  }
  
  $UserName = "john.doe@sharepointonline.co.uk"
  $Password = Read-Host -Prompt "Enter password" -AsSecureString    
  $Url = "https://mycompany.sharepoint.com/sites/COP/SharePoint/john"
  
  $context = Get-SPOContext -Url $Url -UserName $UserName -Password $Password
  $items = Get-ListItems -Context $context -ListTitle "NPT Form" 
  
  foreach($item in $items)
  {
     $item.Id
     $item | gm
  }</code></pre>
  </div>
  </div>
  </p>