기본적인 Powershell의 문법은 아래와 같다.
구문 및 주석처리
Powershell은 스크립트 언어이기 때문에 따로 코드의 영역을 지정하는 양식이나 줄을 구분하는 기호가 없다.
한줄 주석은 sharp(#) 기호를 사용하고 주석 영역은 <# ... #>를 사용한다.
** 주석(comments)는 코드의 직접적인 미치지 않는 설명으로써 코드를 열람하는 사람에게 코드 가용성을 위하여 코드 설명이나 기능 등을 입력할 때 쓰인다.
# .< help keyword>
# <help content>
-or -
<#
.< help keyword>
< help content>
#>
명령어 양식
Verb-Noun
Do something-To something
ex) Get-verb
PS C:\Users\jaehui.yoon> get-verb
Verb Group
---- -----
Add Common
Clear Common
Close Common
Copy Common
Enter Common
Exit Common
Find Common
Format Common
Get Common
Hide Common
Join Common
Lock Common
Move Common
New Common
Open Common
명령어에서 요구 조건을 상세하게 전달하기 위해 명령어에서 추가적으로 입력하는 것이 있는데 이를 parameter라고 한다.
parameter를 입력할 때는 dash(-)를 사용한다.
ex) Get-Command -Verb Get -Noun *DNS*
PS C:\Users\jaehui.yoon> Get-Command -Verb Get -Noun *DNS*
CommandType Name Version Source
----------- ---- ------- ------
Alias Get-DnsServerRRL 2.0.0.0 DnsServer
Function Get-AzCdnSubscriptionResourceUsage 2.1.0 Az.Cdn
Function Get-AzFrontDoorCdnSecret 2.1.0 Az.Cdn
Function Get-AzFrontDoorCdnSecurityPolicy 2.1.0 Az.Cdn
Function Get-DAClientDnsConfiguration 3.0.0.0 RemoteAccess
반응형
'ICT' 카테고리의 다른 글
[PowerShell]3. Inputs and Outputs (0) | 2023.03.23 |
---|---|
[PowerShell] Saving Activie Directory Query Output to CSV (0) | 2023.03.20 |
[ChatGPT] Automation: 주간식단표 자동 업로드 (0) | 2023.02.06 |
RAID(Reduntant Array of Independent Disk) (0) | 2023.01.30 |
[PowerShell]1. What is PowerShell (0) | 2023.01.13 |
댓글