PowerShell/PowerShellScript
둘러보기로 가기
검색하러 가기
PowerShell Script
PowerShell Script의 확장자는 ps1을 사용 한다.
ps1 Command Line Argument
<code class="powershell">Write-Host "Num Args:" $args.Length; foreach ($arg in $args) { Write-Host "Arg: $arg"; } Write-Host $args[0]</code>
기본 문법
<code class="powershell">#--- -eq, -ne, -gt, -lt if (~ -eq $True) { #--- If문 # if (-Not ~) } elseif (~) { } else { } switch (~) { # switch -wildcard (~) { # switch -regex (~) { # switch (1, 2, 3, 4, 5) { ~ {} {$_ -gt 3} {} default {} } for ($i = 0; $i -lt 10; $i++) { } foreach ($arg in $args) { } while (~) { }</code>