I have this Powershell code that works in 2013, but it doesn't work in 2010, although am using a functionality that supposed to work in 2010, my problem is with the where-object, it's not really filtering anything, and retrieving 0 results:

$ListTitle  = Read-Host "Enter the title of your list, then click Enter key..."
$MyList = $Web.Lists[$ListTitle]
$cts = $MyList.ContentTypes
foreach($ct in $cts)
    Write-Host $ct.Name
    $items = $MyList.Items | Where-Object {$_.ContentType.Name -eq $ct.Name}
    Write-Host "Count is "  $items.Count

Here $items count is null, although when trying this on 2013 environment it works perfect.

  • are you seeing any content type name on the line before where-object? in 2010 do you have items in the list? also try to replace where-object to ? {}( both are same just for checking)
    – Waqas Sarwar MVP
    Aug 31, 2014 at 20:56
  • Hi, Waqar, thanks for your reply. Yes, the same lists in both environments with same content type, If I remove the where-object, I could retrieve all results, can you try to check it on your 2010 machine? I have tried it on 2 2010 machines, same case. Aug 31, 2014 at 21:55

1 Answer 1


It might have been changed in some updates since 2014, but it is working now in 2018:


$web = $null
$web = Get-SPWeb "https://contoso.com"

$list = $null
$list = $web.lists["Test documents"]

$list.Items | Where-Object {$_.ContentType.Name -eq "Custom content type" }

Write-Host "End" -BackgroundColor DarkGreen -ForegroundColor Green

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.