about_Preference_Variables

업데이트 날짜: 2014년 5월

적용 대상: Windows PowerShell 2.0, Windows PowerShell 3.0, Windows PowerShell 4.0

항목

기본 설정 변수

간단한 설명

Windows PowerShell의 동작을 사용자 지정하는 변수

자세한 설명

Windows PowerShell는 그 동작을 지정할 수 있는 변수 집합을 포함하고 있습니다. 이러한 "기본 설정 변수"는 GUI 기반 시스템의 옵션처럼 작동합니다.

기본 설정 변수는 Windows PowerShell 운영 환경 및 환경에서 실행되는 모든 명령에 영향을 줍니다. 많은 경우 cmdlet에는 특정 명령에 대한 기본 설정 동작을 재정의하는 데 사용할 수 있는 매개 변수가 있습니다.

다음 표는 기본 설정 변수와 해당 기본값을 나열합니다.

    Variable                             Default Value
    --------                             -------------
    $ConfirmPreference                   High
    $DebugPreference                     SilentlyContinue
    $ErrorActionPreference               Continue
    $ErrorView                           NormalView
    $FormatEnumerationLimit              4
    $LogCommandHealthEvent               False (not logged)
    $LogCommandLifecycleEvent            False (not logged)
    $LogEngineHealthEvent                True (logged)
    $LogEngineLifecycleEvent             True (logged)
    $LogProviderLifecycleEvent           True (logged)
    $LogProviderHealthEvent              True (logged)
    $MaximumAliasCount                   4096
    $MaximumDriveCount                   4096
    $MaximumErrorCount                   256
    $MaximumFunctionCount                4096
    $MaximumHistoryCount                 4096
    $MaximumVariableCount                4096
    $OFS                                 (Space character (" "))
    $OutputEncoding                      ASCIIEncoding object
    $ProgressPreference                  Continue
    $PSDefaultParameterValues            (None - empty hash table)     
    $PSEmailServer                       (None)
    $PSModuleAutoLoadingPreference       All
    $PSSessionApplicationName            WSMAN
    $PSSessionConfigurationName          https://schemas.microsoft.com/PowerShell/microsoft.PowerShell 
    $PSSessionOption                     (See below)
    $VerbosePreference                   SilentlyContinue
    $WarningPreference                   Continue
    $WhatIfPreference                    0

또한 Windows PowerShell는 사용자 기본 설정을 저장하는 다음과 같은 환경을 포함하고 있습니다. 이러한 변수에 대한 자세한 내용은 about_Environment_Variables를 참조하세요.

    Variable                                         
    --------    
    PSExecutionPolicyPreference                     
    PSModulePath                        

기본 설정 변수 작업

이 문서에서는 각 기본 설정 변수를 설명합니다.

특정 기본 설정 변수의 현재값을 표시하려면 변수의 이름을 입력합니다. 이에 대한 응답으로 Windows PowerShell는 값을 제공합니다. 예를 들어 다음 명령은 $ConfirmPreference 변수의 값을 표시합니다.

        PS> $ConfirmPreference
        High

변수의 값을 변경하려면 대입문을 사용합니다. 예를 들어 다음 문은 $ConfirmPreference 변수에 값을 "Medium"을 대입합니다.

        PS> $ConfirmPreference = "Medium"

모든 변수와 마찬가지로 사용자가 설정하는 값은 현재 Windows PowerShell 세션 전용입니다. 값을 모든 Windows PowerShell 세션에 유효하게 만들려면 사용자의 Windows PowerShell 프로필에 추가합니다. 자세한 내용은 about_Profiles를 참조하세요.

원격으로 작업

원격 컴퓨터에서 명령을 실행하는 경우, 원격 명령은 원격 컴퓨터의 Windows PowerShell 클라이언트에서 설정한 기본 설정에만 적용됩니다. 예를 들어 원격 명령을 실행하면 원격 컴퓨터의 $DebugPreference의 값은 Windows PowerShell가 디버깅 메시지에 응답하는 방법을 결정합니다.

원격 명령에 대한 자세한 내용은 about_remote를 참조하세요.

$ConfirmPreference
------------------

Windows PowerShell가 cmdlet 또는 함수를 실행하기 전에 자동으로 사용자에게 확인 프롬프트를 표시하는지 여부를 결정합니다.

$ConfirmPreference 변수의 값(High, Medium, Low)이 cmdlet 또는 함수에 할당된 위험(High, Medium, Low)보다 작거나 같으면 Windows PowerShell는 cmdlet 또는 함수를 실행하기 전에 자동으로 사용자에게 확인 프롬프트를 표시합니다.

$ConfirmPreference 변수의 값이 None이면 Windows PowerShell는 cmdlet 또는 함수를 실행하기 전에 자동으로 사용자에게 프롬프트를 표시하지 않습니다.

세션의 모든 cmdlet과 함수에 대해 확인 동작을 변경하려면 $ConfirmPreference 변수의 값을 변경합니다.

단일 명령에 대해 $ConfirmPreference를 재정의하려면 cmdlet 또는 함수의 Confirm 매개 변수를 사용합니다. 확인을 요청하려면 -Confirm을 사용합니다. 확인을 표시하지 않으려면 -Confirm:$false를 사용합니다.

$ConfirmPreference의 유효한 값:

None: Windows PowerShell이 프롬프트를 자동으로 표시하지 않습니다. 특정 명령에 대해 확인을 요청하려면 cmdlet 또는 함수의 Confirm 매개 변수를 사용합니다.

Low: Windows PowerShell이 낮음, 보통 또는 높음 위험의 cmdlet 또는 함수를 실행하기 전에 확인 프롬프트를 표시합니다.

Medium: Windows PowerShell이 보통 또는 높음 위험의 cmdlet 또는 함수를 실행하기 전에 확인 프롬프트를 표시합니다.

High: Windows PowerShell이 높음 위험의 cmdlet 또는 함수를 실행하기 전에 확인 프롬프트를 표시합니다.

자세한 설명

cmdlet 또는 함수의 작업이 시스템에 크게 영향을 주는 경우(데이터를 삭제하거나 많은 양의 시스템 리소스를 사용하는 작업 등), Windows PowerShell는 작업을 실행하기 전에 자동으로 사용자에게 확인 프롬프트를 표시할 수 있습니다.

예:

    PS> remove-item file.txt

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

위험 예상은 cmdlet 또는 함수의 "ConfirmImpact"라는 특성입니다. 사용자는 이 특성을 변경할 수 없습니다.

시스템에 위험을 초래할 수 있는 cmdlet과 함수는 단일 명령에 대한 확인을 요청하거나 억제하는 데 사용할 수 있는 Confirm 매개 변수를 가지고 있습니다.

대부분의 cmdlet과 함수는 기본 위험 값 (ConfirmImpact) Medium을 사용하고 $ConfirmPreference의 기본값은 High이므로 자동 확인은 거의 일어나지 않습니다. 그러나 $ConfirmPreference의 값을 Medium 또는 Low로 변경하면 자동 확인을 활성화할 수 있습니다.

예제

이 예제에서는 $ConfirmPreference의 기본값의 영향을 보여 줍니다. High 값은 높은 위험 cmdlet과 함수를 확인합니다. 대부분의 cmdlet과 함수는 보통 위험이므로 자동으로 확인되지 않습니다.

          PS> $confirmpreference              #Get the current value of the
          High                                 variable
          
          PS> remove-item temp1.txt           #Delete a file
          PS>                                 #Deleted without confirmation

           
          PS> remove-item temp2.txt -confirm  #Use the Confirm parameter to
                                               request confirmation

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

다음 예제는 ConfirmPreference의 값을 Medium으로 변경한 영향을 보여 줍니다. 대부분의 cmdlet과 함수는 보통 위험이므로 자동으로 확인됩니다. 단일 명령에 대한 확인 프롬프트를 표시하지 않으려면 값을 $false로 지정하고 Confirm 매개 변수를 사용합니다.

            
          PS> $confirmpreference = "Medium"  #Change the value of $ConfirmPreference
          PS> remove-item temp2.txt          #Deleting a file triggers confirmation         
                                     
          Confirm
          Are you sure you want to perform this action?
          Performing operation "Remove File" on Target "C:\temp2.txt".
          [Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"):


          PS> remove-item temp3.txt -confirm:$false   #Use Confirm parameter
                                                       to suppress confirmation
          PS>

$DebugPreference
------------------

Windows PowerShell가 스크립트, cmdlet 또는 공급자에 의해 또는 명령줄의 Write-Debug 명령에 의해 생성된 디버깅 메시지에 응답하는 방법을 결정합니다.

일부 cmdlet은 디버깅 메시지를 표시하며, 이 메시지는 일반적으로 프로그래머 및 기술 지원 전문가를 위한 매우 기술적인 메시지입니다. 기본적으로 디버깅 메시지는 표시되지 않지만 $DebugPreference의 값을 변경하여 디버깅 메시지를 표시할 수 있습니다.

또한 cmdlet의 Debug 일반 매개 변수를 사용하여 특정 명령에 대한 디버깅 메시지를 표시하거나 숨길 수 있습니다. 자세한 내용을 보려면 다음을 입력합니다. "get-help about_commonparameters".

유효한 값:

Stop: 디버그 메시지를 표시하고 실행을 중단합니다. 콘솔에 오류를 씁니다.

Inquire: 디버그 메시지를 표시하고 계속하기를 원하는지 여부를 묻습니다. 참고로 Debug 일반 매개 변수를 명령에 추가하면(명령이 디버깅 메시지를 생성하도록 구성된 경우) $DebugPreference 변수의 값이 Inquire로 변경됩니다.

Continue: 디버그 메시지를 표시하고 실행을 계속합니다.

SilentlyContinue: (기본값) 아무 영향도 없습니다. 디버그 메시지가 표시되지 않고 실행이 중단 없이 계속됩니다.

예제

다음 예제에서는 명령줄에서 Write-Debug 명령을 입력할 때 $DebugPreference의 값을 변경한 영향을 보여 줍니다. 이 변경은 cmdlet과 스크립트에 의해 생성된 메시지를 포함하여 모든 디버깅 메시지에 영향을 줍니다. 또한 예제에서는 단일 명령과 관련된 디버깅 메시지를 표시하거나 숨기는 Debug 일반 매개 변수의 사용을 보여 줍니다.

이 예제에서는 기본값 "SilentlyContinue"의 영향을 보여 줍니다. 디버그 메시지가 표시되지 않고 처리가 계속됩니다. 마지막 명령은 Debug 매개 변수를 사용하여 단일 명령에 대한 기본 설정을 재정의합니다.

        PS> $debugpreference                    # Get the current value of
        SilentlyContinue                          $DebugPreference

        PS> write-debug "Hello, World"
        PS>                                     # The debug message is not
                                                  displayed.

        PS> write-debug "Hello, World" -Debug   # Use the Debug parameter
        DEBUG: Hello, World                     # The debug message is
                                                  is requested.                                                                                                    displayed and confirmation
        Confirm
        Continue with this operation?
        [Y] Yes  [A] Yes to All  [H] Halt Command  [S] Suspend  [?] Help (default is "Y"):

이 예제에서는 "Continue" 값의 영향을 보여 줍니다. 마지막 명령은 값이 $false인 Debug 매개 변수를 사용하여 단일 명령에 대한 메시지를 표시하지 않습니다.

        PS> $debugpreference = "Continue"   # Change the value to "Continue"

        PS> write-debug "Hello, World"
        DEBUG: Hello, World                 # The debug message is displayed
        PS>                                   and processing continues.
                                           

        PS> write-debug "Hello, World" -Debug:$false   
                                            # Use the Debug parameter with
                                              false.
        PS>                                 # The debug message is not
                                              displayed.

이 예제에서는 "Stop" 값의 영향을 보여 줍니다. 마지막 명령은 값이 $false인 Debug 매개 변수를 사용하여 단일 명령에 대한 메시지를 표시하지 않습니다.

        PS> $debugpreference = "Stop"       #Change the value to "Stop"
        PS> write-debug "Hello, World"
        DEBUG: Hello, World
        Write-Debug : Command execution stopped because the shell variable "DebugPreference" is
        set to Stop.
        At line:1 char:12
        + write-debug  <<<< "Hello, World"

        PS> write-debug "Hello, World" -Debug:$false   
                                            # Use the Debug parameter with
                                              $false
        PS>                                 # The debug message is not 
                                              displayed and processing is
                                              not stopped.

이 예제에서는 "Inquire" 값의 영향을 보여 줍니다. 마지막 명령은 값이 $false인 Debug 매개 변수를 사용하여 단일 명령에 대한 메시지를 표시하지 않습니다.

        PS> $debugpreference = "Inquire"
        PS> write-debug "Hello, World"
        DEBUG: Hello, World

        Confirm
        Continue with this operation?
        [Y] Yes  [A] Yes to All  [H] Halt Command  [S] Suspend  [?] Help (default is "Y"):

        PS> write-debug "Hello, World" -Debug:$false   
                                            # Use the Debug parameter with
                                              $false
        PS>                                 # The debug message is not
                                              displayed and processing
                                              continues without interruption.

$ErrorActionPreference
----------------------

Windows PowerShell가 Write-Error cmdlet에 의해 발생한 오류와 같이 명령줄 또는 스크립트, cmdlet 또는 공급자의 종료하지 않는 오류(cmdlet 처리를 중단하지 않는 오류)에 대해 응답하는 방법을 결정합니다.

또한 cmdlet의 ErrorAction 일반 매개 변수를 사용하여 특정 명령에 대한 기본 설정을 재정의할 수 있습니다.

유효한 값:

Stop: 오류 메시지를 표시하고 실행을 중단합니다.

Inquire: 오류 메시지를 표시하고 계속하기를 원하는지 여부를 묻습니다.

Continue(기본값): 오류 메시지를 표시하고 실행을 계속합니다.

Suspend: 자세히 조사할 수 있도록 워크플로 작업을 자동으로 일시 중단합니다. 조사 후 워크플로를 다시 시작할 수 있습니다.

SilentlyContinue: 아무 영향도 없습니다. 오류 메시지가 표시되지 않고 실행이 중단 없이 계속됩니다.

참고:

ErrorAction 일반 매개 변수의 Ignore 값은 $ErrorActionPreference 변수의 유효한 값이 아닙니다. Ignore 값은 저장된 기본 설정으로 사용하기 위한 것이 아니라 명령별로 사용하기 위한 것입니다.

$ErrorActionPreference도 ErrorAction 일반 매개 변수도 Windows PowerShell가 종료하는 오류(cmdlet 처리를 중단하는 오류)에 응답하는 방법에 영향을 주지 않습니다.

ErrorAction 일반 매개 변수에 대한 자세한 내용은 about_CommonParameters(https://go.microsoft.com/fwlink/?LinkID=113216)를 참조하세요.

예제

이 예제에서는 $ErrorActionPreference의 서로 다른 값의 영향 및 단일 명령에 대한 기본 설정을 재정의하기 위한 ErrorAction 일반 매개 변수 사용을 보여 줍니다. ErrorAction 매개 변수는 $ErrorActionPreference 변수와 같은 유효한 값을 가지고 있습니다.

이 예제에서는 기본값인 Continue 값의 영향을 보여 줍니다.

        PS> $erroractionpreference                      
        Continue# Display the value of the preference.          
                                  
        PS> write-error "Hello, World"                  
                                # Generate a non-terminating error.

        write-error "Hello, World" : Hello, World       
                                # The error message is displayed and
                                  execution continues.

        PS> write-error "Hello, World" -ErrorAction:SilentlyContinue
                                # Use the ErrorAction parameter with a 
                                  value of "SilentlyContinue".
        PS>                                             
                                # The error message is not displayed and
                                  execution continues.

이 예제에서는 SilentlyContinue 값의 영향을 보여 줍니다.

        PS> $ErrorActionPreference = "SilentlyContinue"
                                # Change the value of the preference.
        PS> write-error "Hello, World"                  
                                # Generate an error message.
        PS>                     
                                # Error message is suppressed.
        PS> write-error "Hello, World" -erroraction:continue
                                # Use the ErrorAction parameter with a
                                  value of "Continue".
        write-error "Hello, World" -erroraction:continue : Hello, World
                                # The error message is displayed and
                                  execution continues.

이 예제에서는 실제 오류의 영향을 보여 줍니다. 이 경우 명령은 존재하지 않는 파일 nofile.txt를 가져옵니다. 또한 예제에서는 ErrorAction 일반 매개 변수를 사용하여 기본 설정을 재정의합니다.

        PS> $erroractionpreference                      
        SilentlyContinue        # Display the value of the preference.     
                                

        PS> get-childitem -path nofile.txt
        PS>                     # Error message is suppressed.

        PS> $ErrorActionPreference = "Continue" 
                                # Change the value to Continue.

        PS> get-childitem -path nofile.txt
        Get-ChildItem : Cannot find path 'C:\nofile.txt' because it does not exist.
        At line:1 char:4
        + get-childitem  <<<< nofile.txt

        PS> get-childitem -path nofile.txt -erroraction SilentlyContinue
                                # Use the ErrorAction parameter
        PS>                     
                                # Error message is suppressed.
  
        PS> $ErrorActionPreference = "Inquire"          
                                # Change the value to Inquire.
        PS> get-childitem -path nofile.txt

        Confirm
        Cannot find path 'C:\nofile.txt' because it does not exist.
        [Y] Yes  [A] Yes to All  [H] Halt Command  [S] Suspend  [?] Help (default is "Y"): y
        
        Get-ChildItem : Cannot find path 'C:\nofile.txt' because it does not exist.
        At line:1 char:4
        + get-childitem  <<<< nofile.txt

        PS> $ErrorActionPreference = "Continue"                  
                                # Change the value to Continue.
        PS> Get-Childitem nofile.txt -erroraction "Inquire"      
                                # Use the ErrorAction parameter to override
                                  the preference value.

        Confirm
        Cannot find path 'C:\nofile.txt' because it does not exist.         
        [Y] Yes  [A] Yes to All  [H] Halt Command  [S] Suspend  [?] Help (default is "Y"):

$ErrorView
----------

Windows PowerShell에서 오류 메시지의 표시 형식을 결정합니다.

유효한 값

NormalView(기본값): 대부분의 사용자를 위한 자세한 보기. 오류 설명, 오류와 관련된 개체의 이름 및 오류를 야기한 명령의 단어를 가리키는 화살표(<<<<)로 구성됩니다.

CategoryView: 프로덕션 환경을 위한 간결하고 구조화된 보기. 형식은 다음과 같습니다. {Category}: ({TargetName}:{TargetType}):[{Activity}], {Reason}

CategoryView의 필드에 대한 자세한 내용은 Windows PowerShell SDK의 "ErrorCategoryInfo 클래스"를 참조하세요.

예제

이 예제에서는 ErrorView 값의 영향을 보여 줍니다.

이 예제에서는 $ErrorView의 값이 NormalView일 때 오류가 나타나는 방법을 보여 줍니다. 이 경우 Get-ChildItem 명령은 존재하지 않는 파일을 찾기 위해 사용됩니다.

        PS> $ErrorView                         # Verify the value.
        NormalView

        PS> get-childitem nofile.txt           # Find a non-existent file.
        Get-ChildItem : Cannot find path 'C:\nofile.txt' because it does not exist.
        At line:1 char:14
        + get-childitem  <<<< nofile.txt

이 예제에서는 $ErrorView의 값이 CategoryView일 때 같은 오류가 나타나는 방법을 보여 줍니다.

        PS> $ErrorView = "CategoryView"        # Change the value to 
                                                 CategoryView

        PS> get-childitem nofile.txt
        ObjectNotFound: (C:\nofile.txt:String) [Get-ChildItem], ItemNotFoundException

이 예제에서는 ErrorView의 값이 오류 표시에만 영향을 미친다는 것을 보여 줍니다. 즉, $error 자동 변수에 저장된 오류 개체의 구조는 변경되지 않습니다. $error 자동 변수에 대한 자세한 내용은 about_automatic_variables를 참조하세요.

이 명령은 오류 배열(요소 0)의 가장 최근 오류와 연결된 ErrorRecord 개체를 가져오고 목록에 있는 오류 개체의 모든 속성을 서식 설정합니다.

        PS> $error[0] | format-list -property * -force

        Exception    : System.Management.Automation.ItemNotFoundException: Cannot find path
                       'C:\nofile.txt' because it does not exist.
                       at System.Management.Automation.SessionStateInternal.GetChildItems(String path,
                       Boolean recurse, CmdletProviderContext context)
                       at System.Management.Automation.ChildItemCmdletProviderIntrinsics.Get(String path,
                       Boolean recurse, CmdletProviderContext context)
                       at Microsoft.PowerShell.Commands.GetChildItemCommand.ProcessRecord()
        TargetObject          : C:\nofile.txt
        CategoryInfo          : ObjectNotFound: (C:\nofile.txt:String) [Get-ChildItem],
                                ItemNotFoundException
        FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand
        ErrorDetails          :
        InvocationInfo        : System.Management.Automation.InvocationInfo

$FormatEnumerationLimit
-----------------------

화면에 포함된 열거 항목 수를 결정합니다. 이 변수는 기본 개체에 영향을 주지 않으며 화면 표시에만 영향을 줍니다. $FormatEnumerationLimit의 값이 열거 항목 수보다 작으면 Windows PowerShell는 항목이 표시되지 않는다는 것을 나타내기 위해 생략 부호(...)를 추가합니다.

        Valid values: Integers (Int32)
        Default value: 4

예제

이 예제에서는 $FormatEnumerationLimit 변수를 사용하여 열거 항목의 화면 표시를 개선하는 방법을 보여 줍니다.

이 예제의 명령은 컴퓨터에서 실행 중인 모든 서비스를 실행 중인 서비스에 대한 그룹과 중단된 서비스에 대한 그룹의 두 그룹으로 나열하는 표를 생성합니다. Get-Service 명령을 사용하여 모든 서비스를 가져온 다음 파이프라인을 통해 결과를 Group-Object cmdlet에 보내며, 이 cmdlet에서 결과를 서비스 상태별로 그룹화합니다.

결과 화면 표시는 Name 열에 상태를 나열하고 Group 열에 해당 상태를 가진 프로세스를 나열하는 표입니다. (열 레이블을 변경하려면 해시 테이블을 사용합니다. 자세한 내용은 "get-help format-table -examples"의 예제를 참조하세요.)

각 상태에 대해 Group 열에 나열된 최대 4개의 서비스가 있습니다. 나열되는 항목 수를 증가시키려면 $FormatEnumerationLimit의 값을 1000으로 증가시킵니다.

결과 화면 표시에서 Group 열의 목록은 이제 줄 길이에 의해 제한됩니다. 예제의 마지막 명령에서는 Format-Table의 Wrap 매개 변수를 사용하여 각 Status 그룹의 모든 프로세스를 표시합니다.

        PS> $formatenumerationlimit         # Find the current value
        4
        
        PS> get-service | group-object -property status           
                                            # List all services grouped by
                                              status

        Count Name                      Group
        ----- ----                      -----
           60 Running                   {AdtAgent, ALG, Ati HotKey Poller, AudioSrv...}   
           41 Stopped                   {Alerter, AppMgmt, aspnet_state, ATI Smart...}

                                           # The list is truncated after
                                             4 items.


        PS> $formatenumerationlimit = 1000
                                           # Increase the limit to 1000.
        
        PS> get-service | group-object -property status           
                                           # Repeat the command.

        Count Name     Group
        ----- ----     -----
           60 Running  {AdtAgent, ALG, Ati HotKey Poller, AudioSrv, BITS, CcmExec...
           41 Stopped  {Alerter, AppMgmt, aspnet_state, ATI Smart, Browser, CiSvc...


        PS> get-service | group-object -property status | format-table -wrap
                                           # Add the Wrap parameter.

        Count Name       Group
        ----- ----       -----
           60 Running    {AdtAgent, ALG, Ati HotKey Poller, AudioSrv, BITS, CcmExec, Client
                         for NFS, CryptSvc, DcomLaunch, Dhcp, dmserver, Dnscache, ERSvc,   
                         Eventlog, EventSystem, FwcAgent, helpsvc, HidServ, IISADMIN,    
                         InoRPC, InoRT, InoTask, lanmanserver, lanmanworkstation, LmHosts, 
                         MDM, Netlogon, Netman, Nla, NtLmSsp, PlugPlay, PolicyAgent,   
                         ProtectedStorage, RasMan, RemoteRegistry, RpcSs, SamSs, Schedule,
                         seclogon, SENS, SharedAccess, ShellHWDetection, SMT PSVC, Spooler,    
                         srservice, SSDPSRV, stisvc, TapiSrv, TermService, Themes, TrkWks,
                         UMWdf, W32Time, W3SVC, WebClient, winmgmt, wscsvc, wuauserv,
                         WZCSVC, zzInterix}

           41 Stopped    {Alerter, AppMgmt, aspnet_state, ATI Smart, Browser, CiSvc,
                         ClipSrv, clr_optimization_v2.0.50727_32, COMSysApp, CronService, 
                         dmadmin, FastUserSwitchingCompatibility, HTTPFilter, ImapiService,
                         Mapsvc, Messenger, mnmsrvc, MSDTC, MSIServer, msvsmon80, NetDDE, 
                         NetDDEdsdm, NtmsSvc, NVSvc, ose, RasAuto, RDSessMgr, RemoteAccess,    
                         RpcLocator, SCardSvr, SwPrv, SysmonLog, TlntSvr, upnphost, UPS, 
                         VSS, WmdmPmSN, Wmi, WmiApSrv, xmlprov}

$Log*Event
----------

Log*Event 기본 설정 변수는 이벤트 뷰어의 Windows PowerShell 이벤트 로그에 쓰는 이벤트 유형을 결정합니다. 기본적으로 엔진 및 공급자 이벤트만 기록되지만 Log*Event 기본 설정 변수를 사용하여 명령에 대한 기록 이벤트와 같이 로그를 사용자 지정할 수 있습니다.

Log*Event 기본 설정 변수는 다음과 같습니다.

            $LogCommandHealthEvent: Logs errors and exceptions in command initialization
                and processing. Default = $false (not logged).

            $LogCommandLifecycleEvent: 
                Logs the starting and stopping of commands and command pipelines
                and security exceptions in command discovery. Default = $false (not logged).

            $LogEngineHealthEvent: Logs errors and failures of sessions. Default = $true (logged).

            $LogEngineLifecycleEvent: Logs the opening and closing of sessions. 
                Default = $true (logged).

            $LogProviderHealthEvent: Logs provider errors, such as read and write errors,
                lookup errors, and invocation errors. Default = $true (logged).

            $LogProviderLifecycleEvent: Logs adding and removing of Windows PowerShell providers.
                Default = $true (logged). (For information about Windows PowerShell providers, type:
                "get-help about_provider".

Log*Event를 사용하도록 설정하려면 값이 $true인 변수를 입력합니다. 예:

            $LogCommandLifeCycleEvent

            - or -

            $LogCommandLifeCycleEvent = $true

이벤트 유형을 사용하지 않도록 설정하려면 값이 $false인 변수를 입력합니다. 예:

            $LogCommandLifeCycleEvent = $false

사용하도록 설정하는 이벤트는 현재 Windows PowerShell 콘솔에만 유효합니다. 구성을 모든 콘솔에 적용하려면 변수 설정을 사용자의 Windows PowerShell 프로필에 저장합니다.

$MaximumAliasCount
------------------

Windows PowerShell 세션에 허용되는 별칭 수를 결정합니다. 기본값 4096은 대부분의 용도에 충분하지만 요구에 맞게 조정할 수 있습니다.

        Valid values: 1024 - 32768 (Int32)
        Default: 4096
      
        To count the aliases on your system, type: 

(get-alias).count

$MaximumDriveCount
------------------

지정한 세션에 허용되는 Windows PowerShell 드라이브 수를 결정합니다. Windows PowerShell 공급자가 표시하는 파일 시스템 드라이브와 데이터 저장소가 여기에 포함되며 이들은 Alias: 및 HKLM: 드라이브 같은 드라이브로 나타납니다.

        Valid values: 1024 - 32768 (Int32)
        Default: 4096
      
        To count the aliases on your system, type: 

(get-psdrive).count

$MaximumErrorCount
------------------

세션에 대한 오류 기록에 저장되는 오류 수를 결정합니다.

        Valid values: 256 - 32768 (Int32)
        Default: 256

각 보관된 오류를 나타내는 개체는 $Error 자동 변수에 저장됩니다. 이 변수는 각 오류마다 하나씩 오류 기록 개체의 배열을 포함하고 있습니다. 최근 오류는 배열의 첫 번째 개체($Error[0])입니다.

시스템의 오류 수를 세려면 $Error 배열의 Count 속성을 사용합니다. 다음을 입력합니다.

$Error.count

특정 오류를 표시하려면 배열 표기법을 사용하여 오류를 표시합니다. 예를 들어 최근 오류를 보려면 다음과 같이 입력합니다.

                $Error[0]

가장 오래 보관된 오류를 표시하려면 다음과 같이 입력합니다.

                $Error[($Error.Count -1]

ErrorRecord 개체의 속성을 표시하려면 다음과 같이 입력합니다.

                $Error[0] | format-list -property * -force

이 명령에서 Force 매개 변수는 ErrorRecord 개체의 특수 서식을 재정의하며 기존의 형식으로 돌아갑니다.

오류 기록에서 모든 오류를 삭제하려면 오류 배열의 Clear 메서드를 사용합니다.

               PS> $Error.count
               17
               PS> $Error.clear()
               PS>
               PS> $Error.count
               0

오류 배열의 모든 속성과 메서드를 찾으려면 InputObject 매개 변수를 지정하고 Get-Member cmdlet을 사용합니다. 개체 컬렉션을 Get-Member로 파이프하면 Get-Member는 컬렉션에 있는 개체의 속성과 메서드를 표시합니다. Get-Member의 InputObject 매개 변수를 사용하면 Get-Member는 컬렉션의 속성과 메서드를 표시합니다.

$MaximumFunctionCount
------------------

지정한 세션에 허용되는 함수 수를 결정합니다.

        Valid values: 1024 - 32768 (Int32)
        Default: 4096

세션의 함수를 보려면 Windows PowerShell Function 공급자가 표시하는 Windows PowerShell Function: 드라이브를 사용합니다. (Function 공급자에 대한 자세한 내용을 보려면 "get-help function"을 입력합니다.)

현재 세션의 함수를 나열하려면 다음과 같이 입력하세요.

            get-childitem function:

현재 세션의 함수 수를 세려면 다음과 같이 입력하세요.

            (get-childitem function:).count

$MaximumHistoryCount
------------------

현재 세션에 대한 명령 기록에 저장되는 명령 수를 결정합니다.

        Valid values: 1 - 32768 (Int32)
        Default: 4096

명령 기록에 저장되는 명령 수를 결정하려면 다음과 같이 입력하세요.

            (get-history).count

세션 기록에 저장된 명령을 보려면 Get-History cmdlet을 사용합니다. 자세한 내용은 about_History(https://go.microsoft.com/fwlink/?LinkID=113233)를 참조하세요.

참고: Windows PowerShell 2.0에서 $MaximumHistoryCount 변수의 기본값은 64입니다.

$MaximumVariableCount
------------------

자동 변수, 기본 설정 변수 및 명령과 스크립트에서 만드는 변수를 포함하여 지정한 세션에 허용되는 변수 수를 결정합니다.

        Valid values: 1024 - 32768 (Int32)
        Default: 4096

세션의 변수를 보려면 Get-Variable cmdlet 및 Windows PowerShell Variable: 드라이브와 Windows PowerShell 변수 공급자의 기능을 사용합니다. 변수 공급자에 대한 자세한 내용을 보려면 "get-help variable"을 입력합니다.

시스템에서 변수의 현재 수를 찾으려면 다음과 같이 입력합니다.

            (get-variable).count

$OFS
----

출력 필드 구분 기호. 배열이 문자열로 변환될 때 배열의 요소를 구분하는 문자를 지정합니다.

        Valid values: Any string.
        Default: Space

기본적으로 $OFS 변수는 존재하지 않으며 출력 파일 구분 기호는 공백이지만 이 변수를 추가하고 임의의 문자열로 설정할 수 있습니다.

예제

이 예제에서는 배열을 문자열로 변환할 때 공백을 사용하여 값을 구분한다는 것을 보여 줍니다. 이 경우 정수 배열을 변수에 저장한 다음 변수를 문자열로 캐스팅합니다.

       PS> $array = 1,2,3                 # Store an array of integers.       

       PS> [string]$array                 # Cast the array to a string.
       1 2 3                              # Spaces separate the elements

구분 기호를 변경하려면 $OFS 변수에 값을 대입하여 해당 변수를 추가합니다. 올바르게 작동하려면 변수 이름을 $OFS로 지정해야 합니다.

       PS> $OFS = "+"                     # Create $OFS and assign a "+"

       PS> [string]$array                 # Repeat the command
       1+2+3                              # Plus signs separate the elements

기본 동작을 복원하려면 $OFS의 값에 공백(" ")을 대입하거나 변수를 삭제할 수 있습니다. 이 명령은 변수를 삭제한 다음 구분 기호가 공백인지 확인합니다.

       PS> Remove-Variable OFS            # Delete $OFS
       PS>

       PS> [string]$array                 # Repeat the command
       1 2 3                              # Spaces separate the elements
       

$OutputEncoding
---------------

Windows PowerShell가 다른 응용 프로그램에 텍스트를 보낼 때 사용하는 문자 인코딩 방법을 결정합니다.

예를 들어 응용 프로그램이 Windows PowerShell에 Unicode 문자열을 반환하는 경우, 문자를 올바르게 보내려면 값을 UnicodeEncoding으로 변경해야 할 수 있습니다.

        Valid values: Objects derived from an Encoding class, such as
                      ASCIIEncoding, SBCSCodePageEncoding, UTF7Encoding, 
                      UTF8Encoding, UTF32Encoding, and UnicodeEncoding.

        Default: ASCIIEncoding object (System.Text.ASCIIEncoding)

예제

이 예제에서는 Windows의 FINDSTR 명령을 Unicode 문자를 사용하는 언어(예: 중국어)에 대해 지역화된 컴퓨터의 Windows PowerShell에서 작동하게 하는 방법을 보여 줍니다. 첫 번째 명령은 $OutputEncoding의 값을 찾습니다. 값은 인코딩 개체이므로 해당 EncodingName 속성만 표시합니다.

          PS> $OutputEncoding.EncodingName  # Find the current value
          US-ASCII

이 예제에서는 FINDSTR 명령을 사용하여 Test.txt 파일에 존재하는 중국어 문자 2개를 검색합니다. 이 FINDSTR 명령을 Windows 명령 프롬프트(Cmd.exe)에서 실행하면 FINDSTR는 텍스트 파일에서 해당 문자를 찾습니다. 그러나 같은 FINDSTR 명령을 Windows PowerShell에서 실행하면 Windows PowerShell가 문자를 Unicode 텍스트 대신에 ASCII 텍스트로 FINDSTR에 보내기 때문에 문자를 찾을 수 없습니다.

          PS> findstr <Unicode-characters>  # Use findstr to search.
          PS>                               # None found.

명령을 Windows PowerShell에서 작동하도록 만들려면 $OutputEncoding의 값을 Windows용으로 선택한 로캘을 기반으로 하는 콘솔의 OutputEncoding 속성의 값으로 설정합니다. OutputEncoding은 콘솔의 정적 속성이므로 명령에 이중 콜론(::)을 사용합니다.

          PS> $OutputEncoding = [console]::outputencoding
          PS>                               # Set the value equal to the
                                              OutputEncoding property of the
                                              console.
          PS> $OutputEncoding.EncodingName               
          OEM United States
                                            # Find the resulting value.

이 변경의 결과로 FINDSTR 명령은 문자를 찾을 수 있습니다.

          PS> findstr <Unicode-characters>               
          test.txt:         <Unicode-characters>        

# Use findstr to search. It find the
                                          characters in the text file.

$ProgressPreference
-------------------

Windows PowerShell가 스크립트, cmdlet 또는 공급자에 의해 생성된 업데이트를 진행하기 위해 응답하는 방법(Write-Progress cmdlet에 의해 생성된 진행률 표시줄 등)을 결정합니다. Write-Progress cmdlet은 명령의 상태를 표시하는 진행률 표시줄을 만듭니다.

유효한 값:

Stop: 진행률 표시줄을 표시하지 않습니다. 그 대신 오류 메시지를 표시하고 실행을 중단합니다.

Inquire: 진행률 표시줄을 표시하지 않습니다. 계속할 권한에 대한 프롬프트를 표시합니다. Y 또는 A로 회신하면 진행률 표시줄을 표시합니다.

Continue(기본값): 진행률 표시줄을 표시하고 실행을 계속합니다.

SilentlyContinue: 명령을 실행하지만 진행률 표시줄을 표시하지 않습니다.

$PSEmailServer
--------------

전자 메일 메시지를 보내는 데 사용하는 기본 전자 메일 서버를 지정합니다. 이 기본 설정 변수는 전자 메일을 보내는 cmdlet(예: Send-MailMessage cmdlet)에 사용됩니다.

$PSDefaultParameterValues
-------------------------

cmdlet 및 고급 함수의 매개 변수에 대한 기본값을 지정합니다. PSDefaultParameterValues의 값은 키가 cmdlet 이름과 콜론(:)으로 구분된 매개 변수 이름으로 구성되고 값이 사용자 지정 기본값인 해시 테이블입니다.

이 변수는 Windows PowerShell 3.0에서 도입되었습니다.

이 기본 설정 변수에 대한 자세한 내용은 about_Parameters_Default_Values를 참조하세요.

$PSModuleAutoloadingPreference
------------------------------

세션에서 모듈의 자동 가져오기를 사용하도록 및 사용하지 않도록 설정합니다. "All"이 기본값입니다. 이 변수의 값과 상관없이 Import-Module cmdlet을 사용하여 모듈을 가져올 수 있습니다.

유효한 값은

모든 모듈을 처음 사용할 때 자동으로 가져옵니다. 모듈을 가져오려면 모듈의 임의 명령을 가져오거나(Get-Command) 사용합니다.

ModuleQualified

사용자가 모듈에 있는 명령의 모듈로 한정된 이름을 사용할 경우에만 모듈을 자동으로 가져옵니다. 예를 들어 사용자가 "MyModule\MyCommand"를 입력하면 Windows PowerShell이 MyModule 모듈을 가져옵니다.

None 세션에서 모듈 자동 가져오기를 사용하지 않도록 설정합니다. 모듈을 가져오려면 Import-Module cmdlet을 사용합니다.

모듈 자동 가져오기에 대한 자세한 내용은 about_Modules(https://go.microsoft.com/fwlink/?LinkID=144311)를 참조하세요.

$PSSessionApplicationName
---------------------------

WS-Management 기술을 사용하는 원격 명령에 대한 기본 응용 프로그램 이름을 지정합니다.

시스템 기본 응용 프로그램 이름은 WSMAN이지만 이 기본 설정 변수를 사용하여 기본값을 변경할 수 있습니다.

응용 프로그램 이름은 연결 URI의 마지막 노드입니다. 예를 들어 다음과 같은 샘플 URI의 응용 프로그램 이름은 WSMAN입니다.

           http://Server01:8080/WSMAN

기본 응용 프로그램 이름은 원격 명령이 연결 URI 또는 응용 프로그램 이름을 지정하지 않은 경우에 사용됩니다.

WinRM 서비스는 응용 프로그램 이름을 사용하여 연결 요청을 제공하는 수신기를 선택합니다. 이 매개 변수 값은 원격 컴퓨터에 있는 수신기의 URLPrefix 속성 값과 일치해야 합니다.

시스템 기본값 및 이 변수의 값을 재정의하고 특정 세션에 대해 다른 응용 프로그램 이름을 선택하려면 New-PSSession, Enter-PSSession 또는 Invoke-Command cmdlet의 ConnectionURI 또는 ApplicationName 매개 변수를 사용합니다.

이 기본 설정 변수는 로컬 컴퓨터에 설정되지만 원격 컴퓨터의 수신기를 지정합니다. 사용자가 지정하는 응용 프로그램 이름이 원격 컴퓨터에 존재하지 않으면 세션을 설정하기 위한 명령이 실패합니다.

$PSSessionConfigurationName
---------------------------

현재 세션에서 만든 PSSessions에 사용하는 기본 세션 구성을 지정합니다.

이 기본 설정 변수는 로컬 컴퓨터에 설정되지만 원격 컴퓨터에 있는 세션 구성을 지정합니다.

$PSSessionConfigurationName 변수의 값은 정규화된 리소스 URI입니다.

기본값:

         https://schemas.microsoft.com/PowerShell/microsoft.PowerShell 

원격 컴퓨터의 Microsoft.PowerShell 구성을 나타냅니다.

구성 이름만 지정하는 경우 다음 스키마 URI가 추가됩니다.

           https://schemas.microsoft.com/PowerShell/

New-PSSession, Enter-PSSession 또는 Invoke-Command cmdlet의 ConfigurationName 매개 변수를 사용하여 기본값을 재정의하고 특정 세션에 대해 다른 세션 구성을 선택할 수 있습니다.

언제든지 이 변수의 값을 변경할 수 있습니다. 그럴 경우 선택하는 세션 구성이 원격 컴퓨터에 존재해야 합니다. 존재하지 않을 경우 세션 구성을 사용하는 세션을 만들기 위한 명령이 실패합니다.

이 기본 설정 변수는 원격 사용자가 이 컴퓨터에 연결하는 세션을 만들 때 사용되는 로컬 세션 구성을 결정하지 않습니다. 그러나 로컬 세션 구성에 대한 권한을 사용하여 세션 구성을 사용할 수 있는 사용자를 결정할 수 있습니다.

$PSSessionOption
----------------

원격 세션의 고급 사용자 옵션에 대한 기본값을 설정합니다. 이 옵션 기본 설정은 세션 옵션에 대한 시스템 기본값을 재정의합니다.

$PSSessionOption 변수는 PSSessionOption 개체(System.Management.Automation.Remoting.PSSessionObject)를 포함하고 있습니다. 개체의 각 속성은 세션 옵션을 나타냅니다. 예를 들어 NoCompression 속성은 세션 중의 데이터 압축을 끕니다.

기본적으로 $PSSessionOption 변수는 아래와 같은 모든 옵션의 기본값을 가진 PSSessionOption 개체를 포함하고 있습니다.

            MaximumConnectionRedirectionCo For descriptions of these options, see the help topic for the unt : 5
            NoCompression                     : False
            NoMachineProfile                  : False
            ProxyAccessType                   : None
            ProxyAuthentication               : Negotiate
            ProxyCredential                   :
            SkipCACheck                       : False
            SkipCNCheck                       : False
            SkipRevocationCheck               : False
            OperationTimeout                  : 00:03:00
            NoEncryption                      : False
            UseUTF16                          : False
            IncludePortInSPN                  : False
            OutputBufferingMode               : None
            Culture                           :
            UICulture                         :
            MaximumReceivedDataSizePerCommand :
            MaximumReceivedObjectSize         : 209715200
            ApplicationArguments              :
            OpenTimeout                       : 00:03:00
            CancelTimeout                     : 00:01:00
            IdleTimeout                       : -00:00:00.0010000

이 옵션에 대한 설명은 New-PSSessionOption cmdlet에 대한 도움말 항목을 참조하세요.

$PSSessionOption 기본 설정 변수의 값을 변경하려면 New-PSSessionOption cmdlet을 사용하여 사용자가 선호하는 옵션 값을 가진 PSSessionOption 개체를 만듭니다. 출력을 $PSSessionOption이라는 변수에 저장합니다.

예:

            $PSSessionOption = New-PSSessionOption -NoCompression

$PSSessionOption 기본 설정 변수를 모든 Windows PowerShell 세션에 사용하려면 $PSSessionOption 변수를 만드는 New-PSSessionOption 명령을 사용자의 Windows PowerShell 프로필에 추가합니다.

특정 원격 세션에 대한 사용자 지정 옵션을 설정할 수도 있습니다. 사용자가 설정하는 옵션은 시스템 기본값 및 $PSSessionOption 기본 설정 변수의 값보다 우선 적용됩니다.

사용자 지정 세션 옵션을 설정하려면 New-PSSessionOption cmdlet을 사용하여 PSSessionOption 개체를 만듭니다. 그런 다음 세션을 만드는 cmdlet(예: New-PSSession, Enter-PSSession 및 Invoke-Command)의 SessionOption 매개 변수의 값으로 PSSessionOption 개체를 사용합니다.

New-PSSessionOption cmdlet에 대한 자세한 내용은 New-PSSessionOption에 대한 도움말 항목을 참조하세요. 원격 명령과 세션에 대한 자세한 내용은 about_Remote and about_PSSessions를 참조하세요. 프로필 사용에 대한 자세한 내용은 about_Profiles를 참조하세요.

$VerbosePreference
------------------

Windows PowerShell가 스크립트, cmdlet 또는 공급자에 의해 생성된 자세한 정보 메시지에 응답하는 방법(Write-Verbose cmdlet에 의해 생성된 메시지 등)을 결정합니다. 일반적으로 자세한 정보 메시지는 명령을 실행하기 위해 수행한 작업을 설명합니다.

기본적으로 자세한 정보 메시지는 표시되지 않지만 $VerbosePreference의 값을 변경하여 이 동작을 변경할 수 있습니다.

또한 cmdlet의 Verbose 일반 매개 변수를 사용하여 특정 명령에 대한 자세한 정보 메시지를 표시하거나 숨길 수 있습니다. 자세한 내용을 보려면 다음을 입력합니다. "get-help about_commonparameters".

유효한 값:

Stop: 자세한 정보 메시지와 오류 메시지를 표시한 다음 실행을 중단합니다.

Inquire: 자세한 정보 메시지를 표시한 다음 계속할지 여부를 묻는 프롬프트를 표시합니다.

Continue: 자세한 정보 메시지를 표시한 다음 실행을 계속합니다.

SilentlyContinue(기본값): 자세한 정보 메시지를 표시하지 않습니다. 실행을 계속합니다.

예제

이 예제에서는 $VerbosePreference의 서로 다른 값의 영향 및 기본 설정 값을 재정의하기 위한 Verbose 일반 매개 변수 사용을 보여 줍니다.

이 예제에서는 기본값인 SilentlyContinue 값의 영향을 보여 줍니다.

        PS> $VerbosePreference             # Find the current value.
        SilentlyContinue

        PS> Write-Verbose "Verbose message test."              
        PS>                                # Write a verbose message.
                                           # Message is not displayed.

        PS> Write-Verbose "Verbose message test." -verbose     
        VERBOSE: Verbose message test.
                                   # Use the Verbose parameter.

이 예제에서는 Continue 값의 영향을 보여 줍니다.

        PS> $VerbosePreference = "Continue"                    
                                           # Change the value to Continue.
        PS> Write-Verbose "Verbose message test."              
                                           # Write a verbose message.
        VERBOSE: Verbose message test.                         
                                           # Message is displayed.

        PS> Write-Verbose "Verbose message test." -verbose:$false
                                           # Use the Verbose parameter with
                                             a value of $false.
        PS>                                  
                                           # Message is not displayed.

이 예제에서는 Stop 값의 영향을 보여 줍니다.

        PS> $VerbosePreference = "Stop"                        
                                           # Change the value to Stop.
        PS> Write-Verbose "Verbose message test."              
                                           # Write a verbose message.
        VERBOSE: Verbose message test.
        Write-Verbose : Command execution stopped because the shell variable "VerbosePreference"
        is set to Stop.
        At line:1 char:14
        + Write-Verbose  <<<< "Verbose message test."

       PS> Write-Verbose "Verbose message test." -verbose:$false
                                          # Use the Verbose parameter with
                                            a value of $false
       PS>                                  
                                          # Message is not displayed.

이 예제에서는 Inquire 값의 영향을 보여 줍니다.

       PS> $VerbosePreference = "Inquire"                      
                                         # Change the value to Inquire.
       PS> Write-Verbose "Verbose message test."               
       VERBOSE: Verbose message test.
                                         # Write a verbose message.
       Confirm
       Continue with this operation?
       [Y] Yes  [A] Yes to All  [H] Halt Command  [S] Suspend  [?] Help (default is "Y"): y
       PS>

       PS> Write-Verbose "Verbose message test." -verbose:$false
                                        # Use the Verbose parameter.
       PS>                              
                                        # Message is not displayed.

$WarningPreference
------------------

Windows PowerShell가 스크립트, cmdlet 또는 공급자에 의해 생성된 경고 메시지에 응답하는 방법(Write-Warning cmdlet에 의해 생성된 메시지 등)을 결정합니다.

기본적으로 경고 메시지가 표시되고 실행이 계속되지만 $WarningPreference의 값을 변경하여 이 동작을 변경할 수 있습니다.

cmdlet의 WarningAction 일반 매개 변수를 사용하여 Windows PowerShell가 특정 명령에서 오는 경고에 응답하는 방법을 결정할 수도 있습니다. 자세한 내용을 보려면 다음을 입력합니다. "get-help about_commonparameters".

유효한 값:

Stop: 경고 메시지와 오류 메시지를 표시한 다음 실행을 중단합니다.

Inquire: 경고 메시지를 표시한 다음 계속할 권한에 대한 프롬프트를 표시합니다.

Continue(기본값): 경고 메시지를 표시한 다음 실행을 계속합니다.

SilentlyContinue: 경고 메시지를 표시하지 않습니다. 실행을 계속합니다.

예제

이 예제에서는 $WarningPreference의 서로 다른 값의 영향 및 기본 설정 값을 재정의하기 위한 WarningAction 일반 매개 변수 사용을 보여 줍니다.

이 예제에서는 기본값인 Continue 값의 영향을 보여 줍니다.

            PS> $WarningPreference    # Find the current value.                           
            Continue                  

                                      # Write a warning message.
            PS> Write-Warning "This action can delete data."     
            WARNING: This action can delete data.
                                      
                                      # Use the WarningAction parameter to 
                                      # suppress the warning for this command                                             
            PS> Write-Warning "This action can delete data." -warningaction silentlycontinue     

이 예제에서는 SilentlyContinue 값의 영향을 보여 줍니다.

            PS> $WarningPreference = "SilentlyContinue"           
                                      # Change the value to SilentlyContinue.
 
            PS> Write-Warning "This action can delete data."      
            PS>                        # Write a warning message.

       
            PS> Write-Warning "This action can delete data." -warningaction stop     
                                      # Use the WarningAction parameter to stop
                                      # processing when this command generates a
                                      # warning.         
            WARNING: This action can delete data.
            Write-Warning : Command execution stopped because the shell variable
            "WarningPreference" is set to Stop.
            At line:1 char:14
            + Write-Warning <<<<  "This action can delete data." -warningaction stop
                                 

이 예제에서는 Inquire 값의 영향을 보여 줍니다.

           PS> $WarningPreference = "Inquire"                    
                                      # Change the value to Inquire.
           PS> Write-Warning "This action can delete data."   
                                      # Write a warning message.     
           WARNING: This action can delete data.

           Confirm
           Continue with this operation?
           [Y] Yes  [A] Yes to All  [H] Halt Command  [S] Suspend  [?] Help (default is "Y"): y
           PS>

           PS> Write-Warning "This action can delete data." -warningaction silentlycontinue
           PS>                         # Use the WarningAction parameter to change the
                                       # response to a warning for the current command.

이 예제에서는 Stop 값의 영향을 보여 줍니다.

           PS> $WarningPreference = "Stop"                       
                                     # Change the value to Stop.

           PS> Write-Warning "This action can delete data."      
                                     # Write a warning message.
           WARNING: This action can delete data.
           Write-Warning : Command execution stopped because the shell variable 
             "WarningPreference" is set to Stop.
           At line:1 char:14
           + Write-Warning  <<<< "This action can delete data."


           PS> Write-Warning "This action can delete data." -warningaction inquire
           WARNING: This action can delete data.

           Confirm
           Continue with this operation?
           [Y] Yes  [A] Yes to All  [H] Halt Command  [S] Suspend  [?] Help (default is "Y"):                        
                                       # Use the WarningAction parameter to change the
                                       # response to a warning for the current command.

$WhatIfPreference
------------------

WhatIf가 지원하는 모든 명령에 대해 자동으로 사용하도록 설정되는지 여부를 결정합니다. WhatIf가 사용하도록 설정된 경우 cmdlet은 명령의 예상 영향을 보고하지만 명령을 실행하지 않습니다.

유효한 값:

0(기본값): WhatIf가 자동으로 사용하도록 설정되지 않습니다. 수동으로 사용하도록 설정하려면 명령의 WhatIf 매개 변수를 사용합니다.

1: WhatIf가 지원하는 명령에 대해 자동으로 사용하도록 설정됩니다. 사용자는 값이 False인 WhatIf 명령을 사용하여 WhatIf를 수동으로 사용하지 않도록 설정할 수 있습니다(WhatIf:$false).

자세한 설명

cmdlet이 WhatIf를 지정하는 경우 cmdlet은 명령을 실행하는 대신 명령의 예상 영향을 보고합니다. 예를 들어 Windows PowerShell는 Remove-Item 명령에 대한 응답으로 test.txt 파일을 삭제하는 대신 삭제할 내용을 보고합니다. 이후 Get-Childitem 명령에서 파일이 삭제되지 않는다는 것을 확인합니다.

              PS> remove-item test.txt
              What if: Performing operation "Remove-Item" on Target "Item: 
                C:\test.txt
              PS> get-childitem test.txt

              Directory: Microsoft.PowerShell.Core\FileSystem::C:


              Mode                LastWriteTime     Length     Name
              ----                -------------     ------     ----
              -a---         7/29/2006   7:15 PM         84     test.txt

예제

이 예제에서는 WhatIfPreference의 서로 다른 값의 영향을 보여 줍니다. 또한 WhatIf cmdlet 매개 변수를 사용하여 특정 명령에 대해 기본 설정 값을 재정의하는 방법도 보여 줍니다.

이 예제에서는 기본값인 0(사용하도록 설정되지 않음) 값의 영향을 보여 줍니다.

             PS> $whatifpreference                     
             0                         # Check the current value.

             PS> get-childitem test.txt | format-list FullName
             FullName : C:\test.txt
                                       # Verify that the file exists.

             PS> remove-item test.txt                  
             PS>                       # Delete the file.

             PS> get-childitem test.txt | format-list -property FullName
                                       # Verify that the file is deleted.

             Get-ChildItem : Cannot find path 'C:\test.txt' because it does not exist.
             At line:1 char:14
             + get-childitem  <<<< test.txt | format-list fullname

이 예제에서는 $WhatIfPreference의 값이 0일 때 WhatIf 매개 변수 사용의 영향을 보여 줍니다.

             PS> get-childitem test2.txt | format-list -property FullName 
             FullName : C:\test2.txt
                                      # Verify that the file exists.

             PS> remove-item test2.txt -whatif         
             What if: Performing operation "Remove File" on Target "C:\test2.txt".
                                      # Use the WhatIf parameter

             PS> get-childitem test2.txt | format-list -property FullName
             FullName : C:\test2.txt
                                      # Verify that the file was not deleted

이 예제에서는 1(WhatIf 사용하도록 설정) 값의 영향을 보여 줍니다. Remove-Item을 사용하여 cmdlet을 삭제하면 Remove-Item은 삭제할 파일의 경로를 표시하지만 파일을 삭제하지 않습니다.

             PS> $whatifpreference = 1                 
             PS> $whatifpreference
             1                        # Change the value.
                                      
             PS> remove-item test.txt                  
             What if: Performing operation "Remove File" on Target "C:\test.txt".
                                      # Try to delete a file.

             PS> get-childitem test.txt | format-list FullName
             FullName : C:\test.txt
                                      # Verify that the file exists.

이 예제에서는 $WhatIfPreference의 값이 1일 때 파일을 삭제하는 방법을 보여 줍니다. 이때 값이 $false인 WhatIf 매개 변수를 사용합니다.

             PS> remove-item test.txt -whatif:$false
                                      # Use the WhatIf parameter with $false.

이 예제에서는 일부 cmdlet이 WhatIf 동작을 지원하고 다른 cmdlet이 지원하지 않는다는 것을 보여 줍니다. $WhatIfPreference의 값이 1(사용하도록 설정)인 이 예제에서는 WhatIf을 지원하지 않는 Get-Process 명령이 실행되지만 Stop-Process 명령이 WhatIf 동작을 수행합니다. 값이 $false인 WhatIf 매개 변수를 사용하여 Stop-Process 명령의 WhatIf 동작을 재정의할 수 있습니다.

            PS> $whatifpreference = 1                  
                                     # Change the value to 1.
                                                      
            PS> get-process winword  
                                    # A Get-Process command completes.

            Handles  NPM(K)    PM(K)      WS(K) VM(M)   CPU(s)     Id ProcessName
            -------  ------    -----      ----- -----   ------     -- -----------
                234       8     6324      15060   154     0.36   2312 WINWORD


           PS> stop-process -name winword              
           What if: Performing operation "Stop-Process" on Target "WINWORD (2312)".
                                    # A Stop-Process command uses WhatIf.

           PS> stop-process -name winword  -whatif:$false
           PS>                      # WhatIf:$false overrides the preference.
           
           PS> get-process winword                     
           Get-Process : Cannot find a process with the name 'winword'. Verify the process name
            and call the cmdlet again.
           At line:1 char:12
           + get-process  <<<< winword
                                    # Verify that the process is stopped.

참고 항목

about_Automatic_Variables

about_CommonParameters

about_Environment_Variables

about_Profiles

about_Remote about_Scopes