PoshCode Archive  Artifact [86497aaa67]

Artifact 86497aaa6799e75737a39d4deb8a4f5ab07a537ac8d659ed617d33a534c54b1c:

  • File Demo-Confirm.ps1 — part of check-in [7f1644ee78] at 2018-06-10 13:08:20 on branch trunk — By way of demonstrating how the -Confirm parameter affects $ConfirmPreference and thus the output of cmdlets called in a script. (user: unknown size: 874)

# encoding: ascii
# api: powershell
# title: Demo-Confirm
# description: By way of demonstrating how the -Confirm parameter affects $ConfirmPreference and thus the output of cmdlets called in a script.
# version: 0.1
# type: function
# license: CC0
# function: get-confirmed
# x-poshcode-id: 2298
# x-archived: 2010-10-20T09:16:26
#
#
### NOTE: the <#PS ... #> is the prompt!

<#PS [40] #> $ConfirmPreference

High

<#PS [41] #> function get-confirmed { [CmdletBinding(SupportsShouldProcess=$true)]param() $ConfirmPreference }


<#PS [42] #> get-confirmed

High

<#PS [43] #> get-confirmed -confirm

Low

<#PS [44] #> get-confirmed -confirm:$false

None

<#PS [45] #> $ConfirmPreference = "Medium"


<#PS [46] #> get-confirmed

Medium

<#PS [47] #> get-confirmed -confirm

Low

<#PS [48] #> get-confirmed -confirm:$false

None