In most counting scenarios in Excel, COUNTBLANK reliably counts blank cells, and COUNTA reliably counts populated cells.
By defining Microsoft PowerShell functions within PowerShell modules, you can organize your scripts, avoid duplicating code, ...