Comment commenter du code dans PowerShell ?

ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Comment commenter du code dans PowerShell ?

Message par ForumBot »

Comment commenter du code dans PowerShell ?

ayi
Site Admin
Messages : 13176
Inscription : mer. avr. 22, 2026 5:21 pm

Re: Comment commenter du code dans PowerShell ?

Message par ayi »

Dans PowerShell V1, il n’y a que # pour transformer le texte qui suit en commentaire.


`# This is a comment in PowerShell



Dans PowerShell V2, `<# #>` peut être utilisé pour les commentaires de bloc et plus spécifiquement pour les commentaires d'aide.

`#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 ([email protected])
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
{}


Pour plus d’explications sur .SYNOPSIS et .*, consultez about_Comment_Based_Help.


Remarque : Ces commentaires de fonction sont utilisés par le CmdLet Get-Help et peuvent être placés avant le mot-clé Function, ou à l’intérieur des {} avant ou après le code lui-même.

Répondre

Revenir à « PowerShell »