Benutzer-Werkzeuge

Webseiten-Werkzeuge


powershell:confirm

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

Nächste Überarbeitung
Vorhergehende Überarbeitung
ronny:powershell:confirm [2015/02/27 10:06] – angelegt ronnypowershell:confirm [2016/04/02 00:48] (aktuell) – Externe Bearbeitung 127.0.0.1
Zeile 15: Zeile 15:
 But you can also configure the system to automatically confirm operations based upon their impact on the system.  When developers write their cmdlets, they can declare the impact of their commands on the system: "HIGH", "MEDIUM", "LOW" For instance, the Exchange command for Removing a Mailbox is declared to have a HIGH impact.  Stop-Process is defined as "MEDIUM" You can then set the variable: $ConfirmPreference to be the level that you want Automatic confirmation turned on.  In the example below, we try to stop CALC with $ConfirmPreference set at LOW, MEDIUM, and HIGH.  Notice that autoconfirmation kicks in when it is set to LOW or MEDIUM but not when it is set to HIGH. But you can also configure the system to automatically confirm operations based upon their impact on the system.  When developers write their cmdlets, they can declare the impact of their commands on the system: "HIGH", "MEDIUM", "LOW" For instance, the Exchange command for Removing a Mailbox is declared to have a HIGH impact.  Stop-Process is defined as "MEDIUM" You can then set the variable: $ConfirmPreference to be the level that you want Automatic confirmation turned on.  In the example below, we try to stop CALC with $ConfirmPreference set at LOW, MEDIUM, and HIGH.  Notice that autoconfirmation kicks in when it is set to LOW or MEDIUM but not when it is set to HIGH.
  
 +<code>
 PS> Calc PS> Calc
 PS> $ConfirmPreference="low" PS> $ConfirmPreference="low"
Zeile 33: Zeile 34:
 PS> Stop-Process -ProcessName calc PS> Stop-Process -ProcessName calc
 PS> PS>
 +</code>
  
 The default value of $ConfirmPreference is "High". The default value of $ConfirmPreference is "High".
Zeile 40: Zeile 42:
 Jeffrey Snover [MSFT] Jeffrey Snover [MSFT]
 Windows PowerShell/MMC Architect Windows PowerShell/MMC Architect
- 
-  
  
 When confirmation is turned on by $ConfirmPreference, you can turn it off for any individual cmdlet invocation using "-Confirm:$false" You can also use "-Confirm:$false" to turn off default confirmation for high impact cmdlets such as Removing a Mailbox.  Another way to turn off confirmation is by setting $ConfirmPreference to "None"; you can limit the effect by setting $script:ConfirmPreference etc, see "get-help about_scope" for more details. When confirmation is turned on by $ConfirmPreference, you can turn it off for any individual cmdlet invocation using "-Confirm:$false" You can also use "-Confirm:$false" to turn off default confirmation for high impact cmdlets such as Removing a Mailbox.  Another way to turn off confirmation is by setting $ConfirmPreference to "None"; you can limit the effect by setting $script:ConfirmPreference etc, see "get-help about_scope" for more details.
  
 +<code>
 PS> $ConfirmPreference="Medium" PS> $ConfirmPreference="Medium"
 PS> stop-process -ProcessName calc -Confirm:$false PS> stop-process -ProcessName calc -Confirm:$false
Zeile 50: Zeile 51:
 PS> stop-process -ProcessName calc PS> stop-process -ProcessName calc
 PS> PS>
 +</code>
  
 Confirmation may cause your script to fail if it is running in a non-interactive environment, so it is important to know how to turn confirmation off when necessary. Confirmation may cause your script to fail if it is running in a non-interactive environment, so it is important to know how to turn confirmation off when necessary.
Zeile 55: Zeile 57:
 Jon Newman [MSFT] Jon Newman [MSFT]
 Windows PowerShell team Windows PowerShell team
 +
 +Link: http://blogs.msdn.com/b/powershell/archive/2006/12/15/confirmpreference.aspx
 +
 +{{tag>[Powershell]}}
powershell/confirm.txt · Zuletzt geändert: 2016/04/02 00:48 von 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki