PowerShell / PowerShell/platyPS

Export-MamlCommandHelp doesn't include default value for parameter

Open
#801 2 comments 0 reactions 1 assignee View on GitHub

@adityapatwardhan is already working on this.

Since Aug 19, 2025.

Area-MAML
Dominant language
C#
Stars
871
Forks
166
Avg merge
21h 17m
Merged PRs (30d)
1

Description

Prerequisites
  • Write a descriptive title.
  • Make sure you are able to repro it on the latest version
  • Search the existing issues.
Steps to reproduce

I try to include parameter default values documentation using PlatyPS but I can't get it to work. It seems like the default values are not populated by New-CommandHelp and even if they are set explicitly on the CommandHelp object or in the markdown file it seems the value is not picked up by Export-MamlCommandHelp and are missing in the generated MAML file.
Repro steps

function Get-Foo {
    param(
        [String] $Name = 'bar'
    )

    "Foo $Name"
}

$cmdHelp = get-command get-foo | New-CommandHelp
$cmdHelp.ToMarkdownString() # note that default value is empty

$cmdHelp.Parameters[0].DefaultValue = "bar" # set the default value explicitly
$cmdHelp.ToMarkdownString() # verify default value is correct
$cmdHelp | Export-MamlCommandHelp -OutputFolder . -force # create maml file. This will not contain the default value
Get-Content .\Get-Foo-Help.xml # notice that there is no <dev:defaultValue>bar</dev:defaultValue> element
Show-HelpPreview -Path .\Get-Foo-Help.xml # notice the missing default value


Expected behavior
NAME
    Get-Foo

SYNOPSIS
    {{ Fill in the Synopsis }}


SYNTAX
    Get-Foo [-Name <System.String>] [<CommonParameters>]


DESCRIPTION
    {{ Fill in the Description }}


PARAMETERS
    -Name [<System.String>]
        {{ Fill Name Description }}

        Required?                    false
        Position?                    0
        Default value                bar
        Accept pipeline input?       false
        Aliases                      none
        Accept wildcard characters?  false

    <CommonParameters>
        This cmdlet supports the common parameters: Verbose, Debug,
        ErrorAction, ErrorVariable, WarningAction, WarningVariable,
        OutBuffer, PipelineVariable, and OutVariable. For more information, see
        about_CommonParameters (https://go.microsoft.com/fwlink/?LinkID=113216).

INPUTS

OUTPUTS
    System.Object
        {{ Fill in the Description }}


NOTES


        {{ Fill in the Notes }}

    --------- Example 1 ---------

    {{ Add example description here }}


RELATED LINKS
    Online Version
Actual behavior
NAME
    Get-Foo

SYNOPSIS
    {{ Fill in the Synopsis }}


SYNTAX
    Get-Foo [-Name <System.String>] [<CommonParameters>]


DESCRIPTION
    {{ Fill in the Description }}


PARAMETERS
    -Name [<System.String>]
        {{ Fill Name Description }}

        Required?                    false
        Position?                    0
        Default value
        Accept pipeline input?       false
        Aliases                      none
        Accept wildcard characters?  false

    <CommonParameters>
        This cmdlet supports the common parameters: Verbose, Debug,
        ErrorAction, ErrorVariable, WarningAction, WarningVariable,
        OutBuffer, PipelineVariable, and OutVariable. For more information, see
        about_CommonParameters (https://go.microsoft.com/fwlink/?LinkID=113216).

INPUTS

OUTPUTS
    System.Object
        {{ Fill in the Description }}


NOTES


        {{ Fill in the Notes }}

    --------- Example 1 ---------

    {{ Add example description here }}


RELATED LINKS
    Online Version
Error details

Environment data
Name                           Value
----                           -----
PSVersion                      7.5.2
PSEdition                      Core
GitCommitId                    7.5.2
OS                             Microsoft Windows 10.0.26100
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
Version

1.0.1

Visuals

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.