You define the acceptable or non-acceptable attributes directly on the parameter and it throws the error. Some Power Shell parameter validation attributes allow you to specifically permit a null or empty value on an input parameter.
For example, the following code shows a function that does not use any parameter validation for the input parameter $Computer Name.
Perhaps, you wrote one line of code that tells the user the input does not match the desired input. Sometimes it would almost be better to throw an error!
Power Shell parameter validation attributes define what is acceptable for parameter input without needing to write massive amounts of code to handle it.
Though the error messages are fairly clear about the problem, perhaps you want to allow for these conditions to be valid so that the function does not err or give nasty red messages.
There are three parameter validation settings that allow you to accept null or empty values and you can use one or all three.
For example, if you were writing a script that set ACLs on a file, you may want to limit the $Action parameter to Allow or Deny.However, when the parameters are validated, the messages are clear that the parameters are not passing validation.The original example contained messages stating that the arguments could not be bound.You were taught that your program should nicely tell the user what was wrong and how to fix the problem.You may have ended up writing thousands of lines of code to cover every possible scenario where the user could mess up the input.