Disabling the Confirmation Prompt

Scenario/Problem: You need to automatically confirm operations such that a script runs unattended.

Solution: Include the -Confirm parameter with a $false setting.

When running cmdlets discussed in this book, you might receive a confirmation message to confirm the action being processed. If you use these cmdlets in scripts, the script will not run straight through without prompting for the confirmation.

The cmdlets that have a -Confirm optional parameter can be called in unattended mode by passing in -Confirm:$false to the cmdlet, as shown in Listing 2.3.

Listing 2.3. Suppressing the Confirmation Prompt Example

Remove-item *.png -Confirm:$false

Note

Not all cmdlets have a –Confirm parameter. Use the help ...

Get PowerShell™ for SharePoint® 2013 How-To 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.