Ok, this one is perhaps a little silly, but have you ever struggled with writing output involving an integer with an unknown value together with some text? Don’t know what I’m talking about? I don’t blame you!
I mean this kind of output:
1 file processed
2 files processed
0 files processed
125 files processed
The easy way out would be to write something like this:
Write-Output "$int files processed"
This would mean that for int = 1, the output will be “1 files processed”, but hey – who cares right? I have tried using an if-statement to get the desired result, and while it works, the code don’t look pretty.
So I thought I’d take the time to write a proper function for this. I decided to write a full advanced function, which means that it might feel a bit bloated, but luckily copy/paste don’t care about number of lines.
Anyway, here is the code: