문서의 선택한 두 판 사이의 차이를 보여줍니다.
| 양쪽 이전 판 이전 판 다음 판 | 이전 판 | ||
|
windows:powershell [2024/03/05 13:00] kwon37xi |
windows:powershell [2024/12/13 11:26] (현재) kwon37xi [Powershell script from remote / 원격 스크립트 실행] |
||
|---|---|---|---|
| 줄 9: | 줄 9: | ||
| ===== 기본 개인 profile 파일 ===== | ===== 기본 개인 profile 파일 ===== | ||
| * [[https:// | * [[https:// | ||
| + | * Linux 의 '' | ||
| * '' | * '' | ||
| New-Item $profile -force -itemtype file | New-Item $profile -force -itemtype file | ||
| </ | </ | ||
| - | * '' | + | * '' |
| ===== Powershell Core ===== | ===== Powershell Core ===== | ||
| * [[https:// | * [[https:// | ||
| 줄 99: | 줄 100: | ||
| </ | </ | ||
| - | ===== Powershell script from remote ===== | + | ===== Powershell script from remote |
| * [[https:// | * [[https:// | ||
| <code sh> | <code sh> | ||
| - | Invoke-WebRequest -Uri https://raw.githubusercontent.com/thomasmaurer/ | + | # 한방에 실행 |
| - | </ | + | Invoke-Expression (Invoke-WebRequest -Uri "https://example.com/script.ps1").Content |
| - | * [[https:// | + | |
| - | <code sh> | + | |
| - | # Created by Daniel Jean Schmidt | + | |
| - | [Net.ServicePointManager]:: | + | |
| - | $Script = Invoke-RestMethod | + | # Invoke-Expression -> iex, Invoke-WebRequest -> iwr |
| + | iex (iwr -Uri "https://example.com/script.ps1").Content | ||
| - | Invoke-Expression $Script | + | # 스크립트 다운로드 후 실행 |
| + | # 스크립트를 로컬에 다운로드 | ||
| + | Invoke-WebRequest -Uri " | ||
| + | |||
| + | # 다운로드한 스크립트 실행 | ||
| + | PowerShell -File " | ||
| </ | </ | ||
| - | * [[https:// | ||
| - | < | + | * 실행 정책 문제(Execution Policy) : 기본적으로 PowerShell 이 외부 스크립트 실행을 제한할 수도 있다. |
| - | # script 주소는 올바르게 변경할 것. | + | < |
| - | $ScriptFromGitHub = Invoke-WebRequest | + | # 실행시점에 정책 무시 |
| - | Invoke-Expression $($ScriptFromGitHub.Content) | + | powershell.exe -ExecutionPolicy Bypass -Command "iex (iwr -Uri 'https://example.com/script.ps1').Content" |
| + | |||
| + | # 현재 세션의 실행정책 임시 변경 | ||
| + | Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass | ||
| </ | </ | ||
| ===== tail ===== | ===== tail ===== | ||