You can now gracefully handle any of these values by adding all three to the parameter validation for $Computer Name.I have added a write-host to identify that the code has received something that I chose not to process.And Follow the Steps: 1.) Go the Report Parameters and add a parameter with the datatype is string. If you just want to throw an error then simply amend your query SQL to raise an error on the SQL/Server side by adding something like this to the top of your SQL...2.) Check the Hidden checkbox and Allow blank value ckeckbox. In this tip, we'll look at some other enhancements to validating parameters, which will allow us to pass scripts to DBAs and/or developers, to prevent errors or mistakes when running scripts.We'll look at restricting numbers and strings to a set, along with restricting both to follow certain regular expression patterns, and wrapping it up with allowing some parameters to be mandatory while others can be optional.
The above parameter validation approaches help restrict anything from entering a script, though be careful about being too script in a manner that doesn't match your environment.
For example, the following code shows a function that does not use any parameter validation for the input parameter $Computer Name.
Perhaps, the input for $Computer Name is coming from another cmdlet, process, or a file that is unknowingly empty.
The argument "1234" does not belong to the set "2801,2823" specified by the Validate Set attribute.
Supply an argument that is in the set and then try the command again.