ETC

PowerShell 명령 실행 중 확인 단계 생략

H. An 2008. 2. 28. 15:27

PowerShell
2008. 02. 28.
안혁
http://hyok.kr



PowerShell에서 다음 명령과 같이 확인 단계를 가지고 있는 명령이 있습니다.

[PS] C:\>Disable-TransportAgent -Identity 'attachment filtering agent'

Confirm
Are you sure you want to perform this action?
Disabling Transport Agent "attachment filtering agent". A service restart is required for the change to take effect.
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help
(default is "Y"):n

배치 파일을 만들 때에는 이 확인이 방해가 되는데요. -Confirm옵션을 사용하면 확인하지 않고 명령을 실행할 수 있습니다.

[PS] C:\>Disable-TransportAgent -Identity 'attachment filtering agent' -Confirm:$false

여러 명령어를 실행한다면 다음과 같이 변수 설정으로 같은 효과를 얻을 수 있습니다.

[PS] C:\>$ConfirmPreference="None"
[PS] C:\>Disable-TransportAgent -Identity 'attachment filtering agent'
$ConfirmPreference 변수의 기본값은 High입니다. 설정할 수 있는 값은 None, Low, Medium, High 4개 입니다.