다음을 통해 공유


Unblock-File

인터넷에서 다운로드한 파일의 차단을 해제합니다.

구문

Unblock-File
       [-Path] <String[]>
       [-WhatIf]
       [-Confirm]
       [<CommonParameters>]
Unblock-File
       -LiteralPath <String[]>
       [-WhatIf]
       [-Confirm]
       [<CommonParameters>]

Description

Unblock-File cmdlet을 사용하면 인터넷에서 다운로드한 파일을 열 수 있습니다. PowerShell 실행 정책이 RemoteSigned경우에도 실행할 수 있도록 인터넷에서 다운로드한 PowerShell 스크립트 파일의 차단을 해제합니다. 기본적으로 이러한 파일은 신뢰할 수 없는 파일로부터 컴퓨터를 보호하기 위해 차단됩니다.

Unblock-File cmdlet을 사용하기 전에 파일과 해당 원본을 검토하고 안전하게 열 수 있는지 확인합니다.

내부적으로 Unblock-File cmdlet은 인터넷에서 다운로드되었음을 나타내기 위해 값이 "3"인 Zone.Identifier 대체 데이터 스트림을 제거합니다.

PowerShell 실행 정책에 대한 자세한 내용은 about_Execution_Policies참조하세요.

이 cmdlet은 Windows PowerShell 3.0에서 도입되었습니다.

예제

예제 1: 파일 차단 해제

PS C:\> Unblock-File -Path C:\Users\User01\Documents\Downloads\PowerShellTips.chm

이 명령은 PowerShellTips.chm 파일의 차단을 해제합니다.

예제 2: 여러 파일 차단 해제

PS C:\> dir C:\Downloads\*PowerShell* | Unblock-File

이 명령은 이름이 "PowerShell"인 C:\Downloads 디렉터리의 모든 파일을 차단 해제합니다. 모든 파일이 안전한지 확인할 때까지 이와 같은 명령을 실행하지 마세요.

예제 3: 스크립트 찾기 및 차단 해제

The first command uses the *Stream* parameter of the Get-Item cmdlet get files with the Zone.Identifier stream.Although you could pipe the output directly to the **Unblock-File** cmdlet (Get-Item * -Stream "Zone.Identifier" -ErrorAction SilentlyContinue | ForEach {Unblock-File $_.FileName}), it is prudent to review the file and confirm that it is safe before unblocking.
PS C:\> Get-Item * -Stream "Zone.Identifier" -ErrorAction SilentlyContinue
   FileName: C:\ps-test\Start-ActivityTracker.ps1

Stream                   Length
------                   ------
Zone.Identifier              26

The second command shows what happens when you run a blocked script in a PowerShell session in which the execution policy is **RemoteSigned**. The RemoteSigned policy prevents you from running scripts that are downloaded from the Internet unless they are digitally signed.
PS C:\> C:\ps-test\Start-ActivityTracker.ps1
c:\ps-test\Start-ActivityTracker.ps1 : File c:\ps-test\Start-ActivityTracker.ps1 cannot
be loaded. The file c:\ps-test\Start-ActivityTracker.ps1 is not digitally signed. The script
will not execute on the system. For more information, see about_Execution_Policies.

At line:1 char:1
+ c:\ps-test\Start-ActivityTracker.ps1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : SecurityError: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess

The third command uses the **Unblock-File** cmdlet to unblock the script so it can run in the session.
PS C:\> Get-Item C:\ps-test\Start-ActivityTracker.ps1 | Unblock-File

이 명령은 PowerShell 스크립트를 찾고 차단 해제하는 방법을 보여 줍니다.

매개 변수

-Confirm

cmdlet을 실행하기 전에 확인 메시지를 표시합니다.

형식:SwitchParameter
별칭:cf
Position:Named
Default value:False
필수:False
파이프라인 입력 허용:False
와일드카드 문자 허용:False

-LiteralPath

차단을 해제할 파일을 지정합니다. Path달리 LiteralPath 매개 변수의 값은 입력된 대로 정확하게 사용됩니다. 와일드카드로 해석되는 문자는 없습니다. 경로에 이스케이프 문자가 포함된 경우 작은따옴표로 묶습니다. 작은따옴표는 PowerShell에 문자를 이스케이프 시퀀스로 해석하지 않도록 지시합니다.

형식:String[]
별칭:PSPath
Position:Named
Default value:None
필수:True
파이프라인 입력 허용:True
와일드카드 문자 허용:False

-Path

차단을 해제할 파일을 지정합니다. 와일드카드 문자가 지원됩니다.

형식:String[]
Position:0
Default value:None
필수:True
파이프라인 입력 허용:False
와일드카드 문자 허용:True

-WhatIf

cmdlet이 실행되면 어떻게 되는지 보여 주세요. cmdlet이 실행되지 않습니다.

형식:SwitchParameter
별칭:wi
Position:Named
Default value:False
필수:False
파이프라인 입력 허용:False
와일드카드 문자 허용:False

입력

String

파일 경로를 Unblock-File파이프할 수 있습니다.

출력

None

이 cmdlet은 출력을 생성하지 않습니다.

참고

  • Unblock-File cmdlet은 파일 시스템 드라이브에서만 작동합니다.
  • 파일 차단 해제 파일 탐색기의 속성 대화 상자에서 차단 해제 단추와 동일한 작업을 수행합니다.
  • 차단되지 않은 파일에서 Unblock-File cmdlet을 사용하는 경우 이 명령은 차단 해제 파일에 영향을 주지 않으며 cmdlet에서 오류를 생성하지 않습니다.