PowerShell / PowerShell/platyPS

New-CommandHelp throws error when using strict mode

Open
#800 1 comment 0 reactions 1 assignee View on GitHub

@adityapatwardhan is already working on this.

Since Aug 19, 2025.

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 default to strict mode and noticed that New-CommandHelp does not work with that configuration.
Repro steps:


function Get-Foo {'foo'}
Set-StrictMode -Version Latest
Get-Command Get-Foo | New-CommandHelp # this fails

Expected behavior
`New-CommandHelp` should work in strict mode or the limitation should be documented. The workaround to disable strict mode is straightforward, but it took me some time to figure out it was the culprit.
Actual behavior
It fails with error:

New-CommandHelp: The property 'relatedLinks' cannot be found on this object. Verify that the property exists.
Error details
Exception             :
    Type        : System.Management.Automation.PropertyNotFoundException
    ErrorRecord :
        Exception             :
            Type    : System.Management.Automation.ParentContainsErrorRecordException
            Message : The property 'relatedLinks' cannot be found on this object. Verify that the property exists.
            HResult : -2146233087
        CategoryInfo          : NotSpecified: (:) [], ParentContainsErrorRecordException
        FullyQualifiedErrorId : PropertyNotFoundStrict
    TargetSite  :
        Name          : GetAdaptedValue
        DeclaringType : [System.Management.Automation.Language.PSGetMemberBinder]
        MemberType    : Method
        Module        : System.Management.Automation.dll
    Message     : The property 'relatedLinks' cannot be found on this object. Verify that the property exists.
    Source      : System.Management.Automation
    HResult     : -2146233087
    StackTrace  :
   at System.Management.Automation.Language.PSGetMemberBinder.GetAdaptedValue(Object obj, String member)
   at CallSite.Target(Closure, CallSite, Object)
   at Microsoft.PowerShell.PlatyPS.TransformBase.GetRelatedLinks(Object helpItem)
   at Microsoft.PowerShell.PlatyPS.TransformBase.ConvertCmdletInfo(CommandInfo commandInfo)
   at Microsoft.PowerShell.PlatyPS.TransformCommand.Transform(CommandInfo command)
   at Microsoft.PowerShell.PlatyPS.TransformCommand.Transform(IEnumerable`1 command)
   at Microsoft.PowerShell.PlatyPS.NewCommandHelpCommand.ProcessRecord()
   at System.Management.Automation.CommandProcessor.ProcessRecord()
CategoryInfo          : NotSpecified: (:) [New-CommandHelp], PropertyNotFoundException
FullyQualifiedErrorId : PropertyNotFoundStrict,Microsoft.PowerShell.PlatyPS.NewCommandHelpCommand
InvocationInfo        :
    MyCommand        : New-CommandHelp
    ScriptLineNumber : 1
    OffsetInLine     : 23
    HistoryId        : 4
    Line             : Get-Command Get-Foo | New-CommandHelp
    Statement        : New-CommandHelp
    PositionMessage  : At line:1 char:23
                       + Get-Command Get-Foo | New-CommandHelp
                       +                       ~~~~~~~~~~~~~~~
    InvocationName   : New-CommandHelp
    CommandOrigin    : Internal
ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1
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.