다음을 통해 공유


확인 메시지

다음은 호출되는 System.Management.Automation.Cmdlet.ShouldProcessSystem.Management.Automation.Cmdlet.ShouldContinue 메서드의 변형에 따라 표시될 수 있는 다양한 확인 메시지입니다.

중요합니다

확인을 요청하는 방법을 보여 주는 샘플 코드는 확인요청하는 방법을 참조하세요.

리소스 지정

System.Management.Automation.Cmdlet.ShouldProcess 메서드를 호출하여 변경될 리소스를 지정할 수 있습니다. 이 경우 메서드의 target 매개 변수를 사용하여 리소스를 제공하고 Windows PowerShell에서 작업을 추가합니다. 다음 메시지에서 "MyResource" 텍스트는 작동하는 리소스이며 작업은 호출을 수행하는 명령의 이름입니다.

Confirm
Are you sure you want to perform this action?
Performing operation "Test-RequestConfirmationTemplate1" on Target "MyResource".
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"):

사용자가 확인 요청에 대한 예 또는 Yes to All 선택하는 경우(다음 예제와 같이) System.Management.Automation.Cmdlet.ShouldContinue 메서드에 대한 호출이 수행되어 두 번째 확인 메시지가 표시됩니다.

Confirm
Are you sure you want to perform this action?
Performing operation "Test-RequestConfirmationTemplate1" on Target "MyResource".
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"): y

Confirm
Continue with this operation?
[Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"):

작업 및 리소스 지정

변경될 리소스와 System.Management.Automation.Cmdlet.ShouldProcess 메서드를 호출하여 명령이 수행하려는 작업을 지정할 수 있습니다. 이 경우 target 매개 변수를 사용하여 target 매개 변수 및 작업을 사용하여 리소스를 제공합니다. 다음 메시지에서 "MyResource" 텍스트는 수행되는 리소스이고 "MyAction"은 수행할 작업입니다.

Confirm
Are you sure you want to perform this action?
Performing operation "MyAction" on Target "MyResource".
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"):

사용자가 선택하거나 이전 메시지에 대한 모든 예라고 경우 System.Management.Automation.Cmdlet.ShouldContinue 메서드를 호출하여 두 번째 확인 메시지가 표시됩니다.

Confirm
Are you sure you want to perform this action?
Performing operation "MyAction" on Target "MyResource".
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"): y

Confirm
Continue with this operation?
[Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"):

또한 참조하십시오

Windows PowerShell Cmdlet 작성