Edit

Share via


Export-MarkdownCommandHelp

Exports a CommandHelp object to a markdown file.

Syntax

__AllParameterSets

Export-MarkdownCommandHelp
    [-CommandHelp] <CommandHelp[]>
    [-Encoding <Encoding>]
    [-Force]
    [-OutputFolder <string>]
    [-Metadata <hashtable>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

Description

This command exports a CommandHelp object to a markdown file. You can add metadata frontmatter to the markdown file by using the Metadata parameter. You can get a CommandHelp object by using the Export-MarkdownCommandHelp cmdlet or one of the Import-* cmdlets.

Examples

Example 1 - Convert old Markdown help content to the new format

This example imports Markdown help in the old format from the .\v1 folder and exports it to the .\v2 folder in the new format.

$chobj = Import-MarkdownCommandHelp -Path .\v1\Export-YamlModuleFile.md
Export-MarkdownCommandHelp -CommandHelp $chobj -OutputFolder .\v2
    Directory: D:\Git\PS-Src\platyPS\v2docs\v2

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a---           5/20/2024  3:33 PM           2892 Export-YamlModuleFile.md

Example 2 - Convert a folder of old Markdown help content to the new format

This example imports Markdown help in the old format from the .\v1 folder and exports it to the .\v1\new folder in the new format. If necessary, Export-MarkdownCommandHelp creates the destination folders. The new markdown files are written to folder named for the module they belong to.

$mdfiles = Measure-PlatyPSMarkdown -Path .\v1\Microsoft.PowerShell.PlatyPS\*.md
$mdfiles | Where-Object Filetype -match 'CommandHelp' |
    Import-MarkdownCommandHelp -Path {$_.FilePath} |
    Export-MarkdownCommandHelp -OutputFolder .\v1\new
    Directory: D:\Git\PS-Src\platyPS\v2docs\v1\new\Microsoft.PowerShell.PlatyPS

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a---           8/26/2024  3:30 PM           3194 Compare-CommandHelp.md
-a---           8/26/2024  3:30 PM           4282 Export-MamlCommandHelp.md
-a---           8/26/2024  3:30 PM           6401 Export-MarkdownCommandHelp.md
-a---           8/26/2024  3:30 PM           4874 Export-MarkdownModuleFile.md
-a---           8/26/2024  3:30 PM           6429 Export-YamlCommandHelp.md
-a---           8/26/2024  3:30 PM           5601 Export-YamlModuleFile.md
-a---           8/26/2024  3:30 PM           2724 Import-MamlHelp.md
-a---           8/26/2024  3:30 PM           3733 Import-MarkdownCommandHelp.md
-a---           8/26/2024  3:30 PM           3870 Import-MarkdownModuleFile.md
-a---           8/26/2024  3:30 PM           3907 Import-YamlCommandHelp.md
-a---           8/26/2024  3:30 PM           3477 Import-YamlModuleFile.md
-a---           8/26/2024  3:30 PM           2088 Measure-PlatyPSMarkdown.md
-a---           8/26/2024  3:30 PM           4748 New-CommandHelp.md
-a---           8/26/2024  3:30 PM           8647 New-MarkdownCommandHelp.md
-a---           8/26/2024  3:30 PM           5086 New-MarkdownModuleFile.md
-a---           8/26/2024  3:30 PM           3080 Test-MarkdownCommandHelp.md
-a---           8/26/2024  3:30 PM           3041 Update-CommandHelp.md
-a---           8/26/2024  3:30 PM           3981 Update-MarkdownCommandHelp.md
-a---           8/26/2024  3:30 PM           5548 Update-MarkdownModuleFile.md

Parameters

-CommandHelp

The CommandHelp object to export. You can pass the CommandHelp object on the pipeline or by using the Command parameter.

Parameter properties

Type:

Microsoft.PowerShell.PlatyPS.Model.CommandHelp[]

Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:0
Mandatory:True
Value from pipeline:True
Value from pipeline by property name:False
Value from remaining arguments:False

-Confirm

Prompts you for confirmation before running the cmdlet.

Parameter properties

Type:SwitchParameter
Default value:False
Supports wildcards:False
DontShow:False
Aliases:cf

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Encoding

The encoding to use when writing the markdown file. If no value is specified, encoding defaults to the value of the $OutputEncoding preference variable.

Parameter properties

Type:Encoding
Default value:False
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Force

Use the Force parameter to overwrite the output file if it already exists.

Parameter properties

Type:SwitchParameter
Default value:False
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Metadata

The metadata to add to the frontmatter of the markdown file. The metadata is a hashtable where the you specify the key and value pairs to add to the frontmatter. New key names are added to the existing frontmatter. The values of existing keys are overwritten.

Parameter properties

Type:Hashtable
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-OutputFolder

The folder where the markdown file is saved. If the folder doesn't exist, it's created.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-WhatIf

Runs the command in a mode that only reports what would happen without performing the actions.

Parameter properties

Type:SwitchParameter
Default value:False
Supports wildcards:False
DontShow:False
Aliases:wi

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

Inputs

Microsoft.PowerShell.PlatyPS.Model.CommandHelp

Outputs

FileInfo