So far, we have focused on making the code easier to troubleshoot. This chapter will introduce the techniques used to troubleshoot the code while it's running. We will see that the investment we've put into the proper design and implementation of our code will make the job of troubleshooting much easier. The specific techniques that we will cover in this chapter are as follows:
Reading error messages
Using
Set-PSDebug
Debugging in the ISE (or other integrated environment)
Debugging in the console
Event logs
The PSDiagnostics module
Using
–confirm
and–whatif
Reducing input size
Using
Tee-Object
Replacing the
foreach
loop with theforeach-object
cmdlet