none
Office365 get items value with powershell and column display name

    Question

  • Hey,

    I want to build a script in powershell which reads items in a sharepoint online (Office 365) list.

    But I like to get the item properties by calling the columns with their display name. Can anybody help me by the script?

     

    Regards

    Stefan

    Thursday, September 8, 2016 8:05 PM

Answers

  • Try like below, change the url and list name

    $aClient = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client")
    $aClientRuntime = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.Runtime")
    $aClientPub = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.Publishing.dll")
    
    if($Credentials -eq $null)
    {
    	$Credentials = Get-Credential -Message "Enter your credentials"
    }
    
    $Url = "https://crazylabs.sharepoint.com/sites/rajesh"
    
    # SharePoint Online
    $ctx = New-Object Microsoft.SharePoint.Client.ClientContext($Url) 
    $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Credentials.UserName,$Credentials.Password) 
    
    $clientweb = $ctx.Web  
    $ctx.Load($clientweb) 
    $ctx.ExecuteQuery() 
    
    #Retrieve List
    $List = $ctx.Web.Lists.GetByTitle("List001")
    
    $qry = [Microsoft.SharePoint.Client.CamlQuery]::CreateAllItemsQuery()
    $items = $List.GetItems($qry)
    $ctx.Load($items)
    $ctx.ExecuteQuery()
    
    foreach($item in $items)
    {
       $item["Title"]
    }
    
    


    ---
    Rajesh
    rjesh.com| @rjesh
    You don't need to buy me a beer, if helpful just smile, vote, and mark it as answer.

    • Marked as answer by SK3110 Friday, September 9, 2016 2:57 PM
    Thursday, September 8, 2016 11:41 PM

All replies

  • Try like below, change the url and list name

    $aClient = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client")
    $aClientRuntime = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.Runtime")
    $aClientPub = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.Publishing.dll")
    
    if($Credentials -eq $null)
    {
    	$Credentials = Get-Credential -Message "Enter your credentials"
    }
    
    $Url = "https://crazylabs.sharepoint.com/sites/rajesh"
    
    # SharePoint Online
    $ctx = New-Object Microsoft.SharePoint.Client.ClientContext($Url) 
    $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Credentials.UserName,$Credentials.Password) 
    
    $clientweb = $ctx.Web  
    $ctx.Load($clientweb) 
    $ctx.ExecuteQuery() 
    
    #Retrieve List
    $List = $ctx.Web.Lists.GetByTitle("List001")
    
    $qry = [Microsoft.SharePoint.Client.CamlQuery]::CreateAllItemsQuery()
    $items = $List.GetItems($qry)
    $ctx.Load($items)
    $ctx.ExecuteQuery()
    
    foreach($item in $items)
    {
       $item["Title"]
    }
    
    


    ---
    Rajesh
    rjesh.com| @rjesh
    You don't need to buy me a beer, if helpful just smile, vote, and mark it as answer.

    • Marked as answer by SK3110 Friday, September 9, 2016 2:57 PM
    Thursday, September 8, 2016 11:41 PM
  • Hi,

    I want to query the list items from a SP folder based on its item field value.

    Please help me with this.

    Wednesday, August 16, 2017 6:18 AM