Skip to content

New-HelpCabinetFile fails on Windows PowerShell 5.1 because $IsWindows is undefined #842

@kborowinski

Description

@kborowinski

Prerequisites

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

Steps to reproduce

New-HelpCabinetFile currently checks whether the platform is Windows by using the $IsWindows automatic variable:

if (! $IsWindows) {
    throw "'New-HelpCabinetFile' is only supported on Windows."
}

However, $IsWindows is only available in PowerShell Core and is not defined in Windows PowerShell 5.1.

As a result, running New-HelpCabinetFile on Windows PowerShell 5.1 fails even though the cmdlet is intended to be supported on Windows.

Expected behavior

New-HelpCabinetFile should run successfully on Windows PowerShell 5.1.

Actual behavior

The cmdlet fails because $IsWindows is not defined in Windows PowerShell 5.1.

Error details

New-HelpCabinetFile -CabinetFilesFolder D:\TMP\ -MarkdownModuleFile D:\TMP\tmp.md -OutputFolder $PWD
'New-HelpCabinetFile' is only supported on Windows.
At C:\Program Files\WindowsPowerShell\Modules\Microsoft.PowerShell.PlatyPS\1.0.1\Microsoft.PowerShell.PlatyPS.psm1:277 char:13
+             throw "'New-HelpCabinetFile' is only supported on Windows ...
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: ('New-HelpCabine...ted on Windows.:String) [], RuntimeException
    + FullyQualifiedErrorId : 'New-HelpCabinetFile' is only supported on Windows.

Environment data

Name                           Value
----                           -----
PSVersion                      5.1.26100.8328
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0, 5.0, 5.1.26100.8328}
BuildVersion                   10.0.26100.8328
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Version

1.0.1

Visuals

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions