8.5. Using the verbose Parameter

The -verbose parameter tells you what has been done. If you are doing something risky, then the verbose parameter doesn't provide protection against ill-advised actions like the -whatif or =confirm parameters, at least if you haven't worked out the precise effect of the command.

In this example, you will start three copies of the Notepad application and then use Windows PowerShell to stop those three instances but observe the output generated by Windows PowerShell when you use the verbose parameter. The example assumes that you don't have other instances of Notepad running.

Start three Notepad instances by typing these commands:

Notepad
Notepad
Notepad

Confirm that three Notepad processes are running:

get-process Notepad

Now stop the processes by typing:

stop-process -processname Notepad

You can see in Figure 8-17 that no information is given about what actions have been taken although all instances of Notepad are terminated. This will also close any other instances of Notepad you might have and will do so despite your perhaps having unsaved changes.

Figure 8.17. Figure 8-17

To observe the output Windows PowerShell generates with the -verbose parameter, start three new Notepad processes, as described above.

Then stop them using the stop-process command, but this time specifying the verbose parameter as follows:

stop-process -name Notepad -verbose ...

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.