It’s possible to validate input in PowerShell!
There are eight built in functions:
- ValidateNotNull
- ValidateNotNullOrEmpty
- ValidateLength
- ValidateCount
- ValidateRange
- ValidateSet
- ValidatePattern
- ValidateScript
With dynamic typing, I don’t see the importance of one through seven, but eight! Is amazing. Let’s say you need to have the function only fun as administrator. You can throw in a short script block that returns $true when run as admin.
Happy PowerShell!