Finally it works… BUT…
- It’s 26 lines long for this piece of code. If we have multiple then this is going to blow up size wise, and
- There’s definitely more but I think I’ve gotten the point across (or I hope I have).
So let’s try and use what’s built in to PowerShell.
The built-in version is 3 lines of code and provides more functionality. You probably want to use that version; click through to see this all in action.