본문 바로가기

Windows 10/PowerShell

PowerShell : IEX (문자열을 명령어로 실행하기)

반응형

- String으로 된 명령어 실행

$msg = "Write-Host `"글자를 출력하세요.`"

# $msg와 iex $msg를 비교해보세요.
$msg
iex $msg

 

 

Invoke-Expression (Microsoft.PowerShell.Utility)

The Invoke-Expression cmdlet evaluates or runs a specified string as a command and returns the results of the expression or command. Without Invoke-Expression, a string submitted at the command line would be returned (echoed) unchanged.

docs.microsoft.com

 

반응형