Checks for well-known mistakes
Invoke-ScriptAnalyzer -Path .\ConvertTo-Base64.ps1
Findings can be suppressed:
function ConvertTo-Base64 {
[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
"PSProvideCommentHelp",
"",
Justification="Just an example"
)]
#...
}
–
Unit tests in PowerShell with Pester
Import-Module Base64
Describe 'ConvertTo-Base64` {
It 'Accepts parameter' {
{ ConvertFrom 'BlargBlubb' } | Should Not Throw
}
}
Place in separate files (*.Tests.ps1
)
Place in separate filder (\Tests
)
Also supports code coverage
–
function ConvertTo-Base64 {
<#
.SYNOPSIS
Converts strings to Base64
.PARAMETER InputObject
One or more strings
.PARAMETER Encoding
Encoding to use for conversion (default: UTF8)
#>
#...
}
Automatically available through -?
and Get-Help
Also works for scripts
–
Write your help files in markdown with platyPS
Generate markdown help for existing functions:
New-MarkdownHelp -Module MyAwesomeModule -OutputFolder .\docs
Generate PowerShell help files from markdown:
New-ExternalHelp .\docs -OutputPath en-US\
Add another step to your pipeline