Basics | Error Trapping

Error trapping in forms isn't much different than other error trapping in PowerShell. I placed this here due to the fact that when using forms you are usually looking for user input which can cause issues in a script.

0) One of the first and foremost things to use when writting scripts is to use the Try / Catch.

1) Cleaning data, I run multiple forms and one of the best practice for any type of programming is clearing your variables. I do this by a simple double quote statment as shown below or use PowerShell command.

2) Verify that a field was not left blank using a function that I pass all form input to.

I also use $Null instead of "" for checking for blank / null data returns.

3) I also use the trim feature when gathering input because AD will hold a whitepace and that makes serious issues when passwords or SAMAccountNames are entered.

4) I also make sure my date formats are in the format I require. I almost never need the time so I use the following for formating my date variable.

5) I also ue items to verfiy if length is correct for example the minimum password char length is 8.