Skip to content

New-MarkdownHelp 0.14.1 generates bogus errors when using the Session parameter. #509

@chrisda

Description

@chrisda

The newer 0.14.1 version of platyPS does something that the 0.14.0 version does not:

If you use the Session parameter with New-MarkdownHelp (which I'm forced to do with Exchange, since all Exchange PowerShell is remote), the same error is repeated in proportion to the number of parameters in the cmdlet (which is a big deal if you also use the Module parameter; it's a sea of red errors interspersed with successful cmdlet names).

You cannot call a method on a null-valued expression.
At C:\Users\jdoe\Documents\WindowsPowerShell\Modules\platyPS\platyPS.psm1:2678 char:25
+                     if ($Attribute.TypeId.ToString() -eq 'System.Management.Auto ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

I've verified the following aspects:

  • These errors DO NOT occur in 0.14.1 if you omit the Session parameter (again, not a viable option for me, but I confirmed it).
  • These errors DO NOT affect the output of New-MarkdownHelp. I dumped the same cmdlet to a markdown file using the 0.14.0 and 0.14.1 versions of platyPS, and then used WinMerge to confirm that the two markdown files are identical.

Attached are the two markdown files for analysis.
Output.zip

Steps to reproduce

  1. Connect to Exchange Online PowerShell.

  2. Run the following commands:

    $Session = Get-PSSession
    New-MarkdownHelp -Session $Session -Command Get-HostedConnectionFilterPolicy -OutputFolder C:\z_MAML_Generation

Expected behavior

The command should run error free as it does in 0.14.0:

PS C:\Users\jdoe> New-MarkdownHelp -Session $Session -Command Get-HostedConnectionFilterPolicy -OutputFolder C:\z_MAML_Generation

    Directory: C:\z_MAML_Generation

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----         2/26/2021  11:00 AM           3081 Get-HostedConnectionFilterPolicy.md

Actual behavior

The command successfully generates the correct markdown topic, but the the console output contains bogus errors:

PS C:\Users\jdoe> New-MarkdownHelp -Session $Session -Command Get-HostedConnectionFilterPolicy -OutputFolder C:\z_MAML_Generation
You cannot call a method on a null-valued expression.
At C:\Users\jdoe\Documents\WindowsPowerShell\Modules\platyPS\0.14.1\platyPS.psm1:2678 char:25
+ ...         if ($Attribute.TypeId.ToString() -eq 'System.Management.Autom ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At C:\Users\jdoe\Documents\WindowsPowerShell\Modules\platyPS\0.14.1\platyPS.psm1:2678 char:25
+ ...         if ($Attribute.TypeId.ToString() -eq 'System.Management.Autom ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

    Directory: C:\z_MAML_Generation

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----         2/26/2021  11:04 AM           3081 Get-HostedConnectionFilterPolicy.md

Environment data

  • platyPS: 0.14.1
  • Windows 10 Enterprise 20H2, Windows Server 2012 R2 Datacenter, Windows Server 2016 Datacenter
  • Windows PowerShell 5.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-MarkdownWriterIssue concerns conversion to markdownIssue-BugIssue has been identified as a bug in the productNeeds-InvestigationThe behavior reported in the issue is unexpected and needs further investigation.Resolution-Won't FixThe issue won't be fixed, possibly due to compatibility reason.platyps-0.14.2

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions