-WhatIf/-Confirm Parameters
Several of the core PowerShell cmdlets support –whatif
and/or –confirm
parameters. The cmdlets that support these parameters could actually make system changes that cannot be reserved, such as deleting a file.
Consider the following example using these parameters:
PS>New-Item -Type File -Path file.tmp Directory: Microsoft.PowerShell.Core\FileSystem::C:\bookMode LastWriteTime Length Name---- -------------- ------ -----a--- 8/4/2008 10:33 PM 0 file.tmpPS>Remove-Item -Path file.tmp -WhatIfWhat if: Performing operation "Remove File" on Target"C:\book\file.tmp".PS>
Two new cmdlets are demonstrated in the preceding example: New-Item ...
Get Microsoft® SQL Server 2012 Unleashed 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.