The cmdlet Measure-Command will test and evaluate your code to make sure it's as optimal as can be. As a PowerShell scripter for a long time, I've since graduated from how to write code to get the job ...
When writing PowerShell scripts, in a perfect world, we'd all just use cmdlets and functions. After all, the batch file days are behind us! Unfortunately, that's not always possible or even the best ...