LinkedIn

Wednesday, 1 April 2015

Debugging an custom object using Powershell in the Package Manager Console window.

All,

I was just trying to find out what data my collection of custom objects was getting hydrated with. the context doesn't matter but for the record, I was hitting a Sitecore index and duplicates were being rendered in my UI.

I started using the immediate window but it had limitations that were preventing me from getting what I needed.

I wanted to see if all the objects that were hydrated that contained the word "test" hence the "test*".

Anyway, here is what I came up with:

for($i = 0; $i -lt 1000; $i++) // 1000 is a bit high so adjust for your needs
$a = $dte.Debugger.GetExpression("(()results[$i]).Name"); 

if ($a.Value -match "test*") 
Write-Host $a.Value 
}

Here are the results:

  • "testcampaignspeed73" 
  • "testcampaignspeed74"
  • "testcampaignspeed2"
  • "testcampaignspeed23"


And here is the PMC window:









I just wanted to put this out there for myself to remember and for anyone else who needs it.

thanks
Russ