Introduction
You can think about debugging as the art and science of removing bugs from your PowerShell scripts. You may find your script does not always do what you or your users want, both during the development of the script and later, after you have used it in production. Troubleshooting is a process you go through to determine why your script is not doing what you want (and helps you resolve your issues with the script).
There are three broad classes of problems that you encounter:
- Syntax errors
- Logic errors
- Runtime errors
Syntax errors are all too common – especially if your typing is less than perfect. It is so easy to type Get-ChildTiem
as opposed to Get-ChildItem
. The good news is that until you resolve your syntax errors, your script cannot run successfully. There are several ways to avoid syntax errors and to simplify the task of finding and removing them. One simple way is to use a good code editor, such as VS Code. Just like...