☑️ Script Execution Issue
PowerShell Terminal CLI(Command Line Interface)로 스크립트 실행 시 발생 한 이슈
☑️ 원인
> 스크립트 실행 권한 오류
☑️ 배경 & 오류 내용
- OS : Windows 11
- VS Code Terminal → Script 실행 시 오류
- PSSecurityException : 스크립트 보안 오류
- UnauthorizedAccess
☑️ 해결 방안
1. PowerShell 관리자 권한 실행
- 시작 → Powershell 검색
- 관리자로 실행
2. 현재 권한 조회 (Current policy)
- Get-ExecutionPolicy -List : 현재 권한 조회 CLI
- Get-ExecutionPolicy의 옵션은 아래 더보기 링크를 통해 확인할 수 있습니다. (옵션 : -List, -Scope)
3. 권한 변경
- Set-ExecutionPolicy "변경 할 권한" : 아래의 표를 통해 선정
ex) Set-ExecutionPolicy RemoteSigned
☑️ Script 실행 권한
권한 | 설명 |
AllSigned | 로컬 컴퓨터에 작성된 스크립트를 포함하여모든 스크립트 및 구성 파일에 서명 |
Bypass | 아무것도 차단되지 않으며 경고 또는 프롬프트가 없음 |
RemoteSigned | 신뢰할 수 있는 게시자에 의해 서명 Windows 서버 컴퓨터 기본 실행 정책 |
Restricted | 구성 파일을 로드하거나 스크립트를 실행하지 않음 Windows 클라이언트 컴퓨터 기본 실행 정책 |
Undefined | 범위에 대해 실행 정책 설정하지 않고 모든 범위 Undefined 정책이면 Restricted 정책 적용 |
Unrestricted | 서명되지 않은 스크립트를 실행하는 경우 실행하기 전 사용 권한을 묻는 메시지 표시 |
☑️ Reference
VSC PowerShell. After npm updating packages .ps1 cannot be loaded because running scripts is disabled on this system
I design websites in VSC and PowerShell is my default terminal. After updating and deploying a website to firebase earlier, I was prompted to update firebase tools - which I did using npm. Immedia...
stackoverflow.com
Set-ExecutionPolicy (Microsoft.PowerShell.Security) - PowerShell
이 cmdlet은 Set-ExecutionPolicy Windows 컴퓨터에 대한 PowerShell 실행 정책을 변경합니다. 자세한 내용은 about_Execution_Policies를 참조하세요. Windows가 아닌 컴퓨터의 경우 PowerShell 6.0부터 기본 실행 정책은 U
learn.microsoft.com