I don't know if you've had to trace down a problem in a PowerShell script before, but sometimes it's helpful to watch how the code progresses (see what loops run, what gets skipped, etc..).  Set-PSDebug -Trace 1 can help you find there.

If you are dealing with large amounts of code, that output can quickly become overwhelming.  If you want to narrow down the code you are watching you can use this little trick to conditionally enable tracing...

Want more great reading? Check out my reading list!