본문 바로가기

반응형

전체보기

(305)
PowerSehll : Try, Catch, Finally (예외 처리) - Try, Catch, Finally Try{ 에러나는이상한문자 } Catch{ Write-Host "이상한 문자가 있던데요?" Write-Host $_ }finally{ Write-Host "에러와 상관없이 실행할꺼야!" } $_ : 에러 표출을 위해 사용 about_Try_Catch_Finally About Try Catch Finally In this article --> SHORT DESCRIPTION Describes how to use the Try, Catch, and Finally blocks to handle terminating errors. LONG DESCRIPTION Use Try, Catch, and Finally blocks to respond to or handle term..
PowerShell : Array, 동적 배열 - 배열 선언 # 첫 번째 방법 $arr = 1, 2, 3, 4, 5 # 두 번째 방법 $arr = 1..5 # 세 번째 방법 (Size가 0인 Array) $arr = @() # 네 번째 방법 (동적 할당) $arr = New-Object System.Collections.ArrayList [void]$arr.Add(1) $arr.Add(2) [void]$arr.Add(3) $arr.Add(4) [void]$arr.Add(5) - 배열 출력 $arr = 10, 20, 30, 40 # 첫 번째 방법 $arr # 두 번째 방법 $arr[0..2] # 세 번째 방법 for($i=0; $i -lt $arr.count; $i++) { Write-Host $arr[$i] } # 네 번째 방법 (숫자 형식인 경우에..
PowerShell : Switch - Switch $i=0 switch($i) { 0 {Write-Host "0000"} 1 {Write-Host "1111"} 2 {Write-Host "2222"} } switch("도망") { '도망' {Write-Host "Run"} 0 {Write-Host "0000"} 1 {Write-Host "1111"} 2 {Write-Host "2222"} } about_Switch About Switch In this article --> SHORT DESCRIPTION Explains how to use a switch to handle multiple If statements. LONG DESCRIPTION To check a condition in a script or function, use an..
PowerSehll : For, While, Break - For For($i=0; $i -lt 10; $i++){ Write-Host $i } about_For About For In this article --> Short description Describes a language command you can use to run statements based on a conditional test. Long description The For statement (also known as a For loop) is a language construct you can use to create a loop that docs.microsoft.com - While $i=0 While($i -lt 6){ Write-Host $i $i++ } about_While ..
PowerShell : If, ElseIf, Else - 조건문 비교 연산자 조건문 비교시 보통의 연산자인 =, 기호 대신 약자를 사용한다. -eq : == -ne : != -lt : = - IF문 $name = "Seoul" if($name -eq "seoul"){ Write-Host "seoul == Seoul" } if($name -eq "Seoul"){ Write-Host "Seoul == Seoul" } - IF & ELSEIF $name = "Seoul" if($name -eq "Busan"){ Write-Host "Busan != Seoul" }elseif($name -eq "Seoul"){ Write-Host "Seoul == Seoul" } - IF & ELSE $name = "Seoul" if($name -eq "Busan"){ Write..
PowerShell : 주석 처리 - 한줄 주석 처리 #한줄 주석 처리 - 블록 주석 처리 방법 about_Comment_Based_Help In this article --> SHORT DESCRIPTION Describes how to write comment-based help topics for functions and scripts. LONG DESCRIPTION You can write comment-based help topics for functions and scripts by using special help comment keywords. The Get-Help cmdlet docs.microsoft.com
PowerShell : 입력 & 출력 - 간단한 입력 $input = Read-Host "입력해줘~" - 간단한 출력 Write-Host "출력해줘~" - 출력값 색 바꾸기 Write-Host "출력해줘~" -foregroundcolor green Write-Host "출력해줘~" -backgroundcolor green - 변경 가능한 색 목록 Black, DarkBlue, DarkGreen, DarkCyan, DarkRed, DarkMagenta, DarkYellow, Gray, DarkGray, Blue, Green, Cyan, Red, Magenta, Yellow, White Write-Host (Microsoft.PowerShell.Utility) The Write-Host cmdlet customizes output. You ca..
PowerShll : 관리자로 실행 첨부된 레지스트리를 추가하면 스크립트를 관리자로 실행 가능.

반응형