-
Notifications
You must be signed in to change notification settings - Fork 1
Standards
Andrew Davidson edited this page Dec 21, 2020
·
14 revisions
Modules should
- have one or more functions in them
- have a valid accompanying module manifest
Module manifests should
- have all functions from the module referenced in the FunctionsToExport property
Module functions and script files should
- have help text detailing the function of the code at the top (For functions this must be inside the function)
- have a [CmdletBinding()] property
- have an [OutputType()] property that must contain one or more OutputTypes
- have a param block
- have any parameters in the param block detailed with a .PARAMETER in the help text
- have variable types for all parameters
- have the keyword function and the name of the function on the same line
- use PowerShell approved verbs and singular nouns. For approved verbs see (for v5.1) or (for v7.1)
An example of a valid functions layout:
function Get-File {
<#
.SYNOPSIS
Get the content of the file
.DESCRIPTION
Get and return the content of the passed PowerShell file
.PARAMETER Path
A string containing PowerShell filename
.EXAMPLE
Get-File -Path $File
#>
[CmdletBinding()]
[OutputType([System.String[]])]
param (
[parameter(Mandatory = $true)]
[string]$Path
)
$fileContent = Get-Content -Path $Path -Raw
return $fileContent
}