cmdlets - User input in automated powershell scripts -
i writing powershell script executes several powershell cmdlets sequentially. 1 of cmdlets among them asks user input [y/n]. want pass value y always. there way this?
sounds need change $confirmpreference
variable.
from output of get-help about_preference_variables
:
$confirmpreference ------------------ determines whether windows powershell automatically prompts confirmation before running cmdlet or function. when value of $confirmpreference variable (high, medium, low) less or equal risk assigned cmdlet or function (high, medium, low), windows powershell automatically prompts confirmation before running cmdlet or function. if value of $confirmpreference variable none, windows powershell never automatically prompts before running cmdlet or function.
so, in order suppress confirmation message, do:
$confirmpreference = "none" <# script here #>
you can on per-cmdlet basis, -confirm:$false
parameter:
set-aduser -description $desc -confirm:$false
note works if cmdlet supports common parameter confirmation. won't have impact on homegrown cmdlets funky self-made confirmation logic
Comments
Post a Comment