Powershell 원격지 실행 about singing (remotesigned)

원격지실행명령어

 

  1. 스크립트서명방식에대한설명
    1. Get-help about signing

 

  1. 원격명령을통해 ps1 파일을실행하는방법

Set-ExecutionPolicy remotesigned

 

 

파라미터

 

Step 1 :파라미터 확인
Get-Help명령어로 기본
Parameter의 도움말을 제공받을 수 있습니다.

Get-Helpabout_CommonParameters

Step 2 : ErrorAction
SilentlyContinue인자를 이용해서 에러 발생해도 출력되지 않고 명령어를 계속 실행할 수 있습니다
.
Stop-Process13,23ErrorActionSilentlyContinue
Stop인자를 이용해서 에러 발생시 명령을 중단합니다.
Stop-Process13,23ErrorActionStop

Step 3 : ErrorVariable
ErrorVariable을 이용해서 에러 발생시 에러 내용을 변수에 저장할 수 있습니다
.
Stop-Process13,23ErrorVariableerrErrorActionSilentlyContinue
아래의 Script이용해서에러내용을일반평문이아닌클래스구조체형식으로정보를제공받을있습니다.
$err[0] | fl*Force
Count속성을 이용해서 에러 발생 개수를 확인할 수 있습니다.
$err.count

Step 4 : OutVariable
OutVariable파라미터를 이용해서 출력을 변수에 저장할 수 있습니다
.
Get-ProcessOutVariableoutput |out-null

Step 5 : Whatif
Whatif를 이용해서 명령어를 테스트할 수 있습니다
.
remove-itemsd.txtwhatif

PS C:\Users\hong.sungho\Desktop> Remove-Item tq.pcy -whatif

WhatIf: 대상 “C:\Users\hong.sungho\Desktop\tq.pcy”에서 “파일 제거” 작업을 수행합니다

글쓴이