I have created some custom PowerShell Cmdlets in C# and would like to provide some information to be displayed using the get-help cmdlet; e.g. “get-help my-cmdlet”.
I have created a basic snapin deriving from PSSnapIn and overridden the Description, Name and Vendor properties. I have also created my help file “Cmdlets.dll-Help.xml”. Cmdlets.dll is the correct name of the assembly as instructed here.
I created the following script to quickly test this help out:
$ErrorActionPreference = "Stop"
$scriptFolder = Split-Path $script:MyInvocation.MyCommand.Path
$dll = ($scriptFolder + "\Release\x64\Cmdlets.dll")
Write-Host "Testing Cmdlets in $dll" -fore Green
[System.Reflection.Assembly] $assembly = [System.Reflection.Assembly]::LoadFrom($dll)
Import-Module -assembly $assembly
This seems to just turn up some default help about the cmdlet parameters but fails to get any of my examples I have written in the XML file. Does anyone have any thoughts on why this is?
Seems like there were two issues for my help not working. First was that the XML needs to be copied to the output directory of the Cmdlet DLL in order for Powershell to be picked up.
Second reason seems to have been an error in my help file. I’m not sure what this was but Powershell just seemed to fail silently even though the error action preference was set to stop. I ended up lifting XML straight out of C:\Windows\System32\WindowsPowerShell\v1.0\en-US\Microsoft.PowerShell.Commands.Management.dll-Help.xml and modifying it to suit my needs.