<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Where on Matt Thornton</title>
    <link>https://matt-thornton.net/tags/where/</link>
    <description>Recent content in Where on Matt Thornton</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en</language>
    <lastBuildDate>Tue, 14 Feb 2012 12:35:49 +0000</lastBuildDate><atom:link href="https://matt-thornton.net/tags/where/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Quick tip: SharePoint powershell - get items in a list based on custom columns and other hints</title>
      <link>https://matt-thornton.net/tech/powershell-tech/quick-tip-sharepoint-powershell-get-items-in-a-list-based-on-custom-columns-and-other-hints/</link>
      <pubDate>Tue, 14 Feb 2012 12:35:49 +0000</pubDate>
      
      <guid>https://matt-thornton.net/tech/powershell-tech/quick-tip-sharepoint-powershell-get-items-in-a-list-based-on-custom-columns-and-other-hints/</guid>
      
        <description>&lt;p&gt;This may be handy when trying to find specific items in a list based on values of various fields:&lt;/p&gt;
&lt;pre&gt;$web = Get-SPWeb http://yourweb
$list = $web.Lists[&#34;Your Library Name&#34;]

// this is the bit - get items of a particular content type
// ? is shorthand for where, and $_ is the item in the pipeline
$listItems = $list.Items | ?{$_.ContentType.Name -eq &#34;Content Type Name&#34;}

// or items based on a custom column - if using -like then the wildcard is *
$listItems = $list.Items | ?{$_[&#34;InternalFieldName&#34;] -like &#34;*this*&#34;

// you could join them up using -and
$listItems = $list.Items | ?{$_.ContentType.Name -eq &#34;Content Type Name&#34; -and $_[&#34;InternalFieldName&#34;] -like &#34;*this*&#34;

// or iterate the loop and print them out
foreach($item in $listItems) { Write-Host $item.Name, $item[&#34;InternalFieldName&#34;] }

or more directly

$list.Items | ?{$_.ContentType.Name -eq &#34;Content Type Name&#34; -and $_[&#34;InternalFieldName&#34;] -like &#34;*this*&#34; | foreach { $_.Name, $_[&#34;InternalFieldName&#34;]

// or count them
$listItems.Count

or

$list.Items | ?{$_.ContentType.Name -eq &#34;Content Type Name&#34; -and $_[&#34;InternalFieldName&#34;] -like &#34;*this*&#34; | foreach {$count++}
$count
&lt;/pre&gt;
&lt;p&gt;Powershell can be infuriating - but when you find the syntax, it can be pretty helpful.&lt;/p&gt;</description>
      
    </item>
    
  </channel>
</rss>