Tidier PowerShell Scripts with Default Parameter Values
I was recently working on a PowerShell script to set up some new databases for my users and found myself writing the same things over and over again.
|
|
By the 4th Invoke-DbaQuery
, I found myself thinking “this repetitive typing kind of sucks.” Then I remembered Chrissy LeMaire’s segment in the first PSPowerHour where she talked about default values, and her accompanying dbatools blog post. Most of the blog posts and demos of this feature focus on using it from the command line, so I had overlooked the fact that I could use it from within a script as well, and even change the values when looping.