8.6. Summary

In this chapter, I described three parameters that are available on cmdlets that alter system state. The parameters provide either some protection against unintended changes in system state or feedback on changes made in system state.

The -whatif parameter allows you to test the effect of a command or pipeline without actually making any change in system state.

The -confirm parameter allows you to make a decision about each potential change in system state. You have options to proceed with or not to proceed with individual actions that affect system state.

The -verbose parameter provides additional information about the effects of a command, if the cmdlet supports the parameter.

In demonstrating the use of the preceding parameters, I introduced you to the following cmdlets, which can change system state:

  • remove-item

  • stop-service

  • stop-process

and demonstrated how you could use them with the -whatif, -confirm and -verbose parameters.

Get Professional Windows® PowerShell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.