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


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.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s