PowerShell: programmatic access to documentation script

Is there a way to programmatically download the documentation for a .ps1 script file outside of commands like get-help? In other words, is it possible to access a text file defined under .SYNOPSIS, DESCRIPTION, etc. Programmatically, other than filtering the output of the get-help string itself?

Among other things, I'm trying to find where I have spaces in the scope of the documentation in my script library. I would also like to be able to display lists of specific scripts with their synopsis attached.

+3
source share
1 answer

Yes, they are all available. Get-Helpreturns (like any other cmdlet) an object, and the default rendering of this object is what you see on the console.

However, if you pump Get-Helpthrough format-list, for example:

get-help get-childitem | format-list

You will get a list of name-value pairs of properties. To get synopsis, you can do the following:

get-help get-childitem |select-object -property synopsis

And the conclusion:

Synopsis
--------
Gets the files and folders in a file system drive.

If your file .ps1does not have the cmdlets defined in it (your help based on comments covers the entire script) get-help file.ps1|select synopsisshould work. Otherwise, you will need “dot-source” files to load cmdlet definitions into memory, then use Get-Helpas described above.

+4
source

All Articles