code

PowerShell에서 코드를 어떻게 주석 처리합니까?

codestyles 2020. 9. 28. 09:11
반응형

PowerShell에서 코드를 어떻게 주석 처리합니까?


PowerShell (1.0 또는 2.0)에서 코드를 어떻게 주석 처리합니까?


PowerShell V1에서는 #주석 뒤에있는 텍스트 작성하면됩니다.

# This is a comment in Powershell

PowerShell V2에서는 <# #>블록 주석, 특히 도움말 주석에 사용할 수 있습니다.

#REQUIRES -Version 2.0

<#
.SYNOPSIS
    A brief description of the function or script. This keyword can be used
    only once in each topic.
.DESCRIPTION
    A detailed description of the function or script. This keyword can be
    used only once in each topic.
.NOTES
    File Name      : xxxx.ps1
    Author         : J.P. Blanc (jean-paul_blanc@silogix-fr.com)
    Prerequisite   : PowerShell V2 over Vista and upper.
    Copyright 2011 - Jean Paul Blanc/Silogix
.LINK
    Script posted over:
    http://silogix.fr
.EXAMPLE
    Example 1
.EXAMPLE
    Example 2
#>
Function blabla
{}

에 대한 자세한 설명은 .SYNOPSIS하고 .*about_Comment_Based_Help을 .

알아두기 :이 기능 코멘트에 의해 사용되는 Get-Helpcmdlet 및 키워드 전에 넣어 수 있습니다 Function, 또는 내부 {}전이나 코드 자체 후.


이렇게 해시 마크를 사용합니다

# This is a comment in Powershell

Wikipedia에는 ​​여러 인기 언어로 댓글을 작성하는 방법을 추적 할 수있는 좋은 페이지가 있습니다.

http://en.wikipedia.org/wiki/Comparison_of_programming_languages_(syntax)#Comments


그것은 #.

특수 문자는 PowerShell-특수 문자 및 토큰참조하세요 .


한 줄 주석은 해시 기호로 시작하며 의 오른쪽에있는 모든 내용 #은 무시됩니다.

# Comment Here

PowerShell 2.0 이상에서는 여러 줄 블록 주석을 사용할 수 있습니다.

<# 
  Multi 
  Line 
#> 

블록 주석을 사용하여 명령 내에 주석 텍스트를 포함 할 수 있습니다.

Get-Content -Path <# configuration file #> C:\config.ini

참고 : PowerShell은 탭 완성지원하므로 Space + TAB주석 앞에 복사 및 붙여 넣기에주의해야합니다 .


여기

# Single line comment in Powershell

<# 
--------------------------------------
Multi-line comment in PowerShell V2+ 
-------------------------------------- 
#>

PowerShell ISE 내에서 Ctrl+ J를 눌러 Start Snipping 메뉴 를 열고 Comment block을 선택할 수 있습니다 .

enter image description here


당신은 할 수 있습니다:

 (Some basic code) # Use "#" after a line and use:

 <#
    for more lines
    ...
    ...
    ...
    ..
    .
 #>

참고 URL : https://stackoverflow.com/questions/7342597/how-do-you-comment-out-code-in-powershell

반응형