Last Updated: February 25, 2016
·
530
· solsila

That annoying Powershell behavior...

I was working on a Powershell script sometime back when I realized that running a foreach block on a $null in Powershell actually iterates through the code block. Quite counterintuitive...

Make sure to include a check for $null within the foreach block to avoid unexpected exceptions!