title: SharePoint > Powershell > How to Get person field's Display Name?
body: <p>I am running the following ps script to get some data out to csv. The person fields (AssignedTo and CreatedBy) come with index;#LastName, FirstName. How do just get the name without the index stuff. Or do I need to do a Regex or Replace? For example,</p>
  
  <p>32;#Doe, John  Should be Doe, John</p>
  
  <pre><code>$results = @()
  $web = Get-SPWeb "http://ourlocal.company.cc/docs/sales"
  $list = $web.Lists["Sales Tasks"]
  $caml = '&lt;Where&gt;&lt;Eq&gt;&lt;FieldRef Name="Status" /&gt;&lt;Value Type="Choice"&gt;Completed&lt;/Value&gt;&lt;/Eq&gt;&lt;/Where&gt;'
  $query=new-object Microsoft.SharePoint.SPQuery
  $query.Query=$caml
  $ListItems=$list.GetItems($query)
  Write-Host "count " $ListItems.Count
  foreach ($item in $listItems)
  {
           $Title = $item["Title"]
           $AssignedTo = $item["AssignedTo"]
           $Status = $item["Status"]
           $Priority = $item["Priority"]
           $CreatedBy = $item["Created By"]
  
           $out = new-object psobject -Property @{Title = $Title
                         AssignedTo = $AssignedTo
                         Status = $Status
                         Priority = $Priority
                         "Due Date" = $DueDate
                         "Percent Complete" = $Percent
                         "Created by" = $CreatedBy}
  
  
          $out = $out|select-object Title, AssignedTo, Status, Priority, "Due Date", "Percent Complete", "Created by"
          $results +=$out
      }
  $results | Export-Csv "c:\output.csv" -noType
  $web.Dispose()
  </code></pre>