Skip to content

PSDiagnostics does not properly export all cmdlets in PSv6 #8339

Closed

Description

Steps to reproduce

PS> Get-Module -ListAvailable PSDiagnostics | select -exp ExportedCommands

Key                          Value
---                          -----
Disable-PSTrace              Disable-PSTrace
Disable-PSWSManCombinedTrace Disable-PSWSManCombinedTrace
Disable-WSManTrace           Disable-WSManTrace
Enable-PSTrace               Enable-PSTrace
Enable-PSWSManCombinedTrace  Enable-PSWSManCombinedTrace
Enable-WSManTrace            Enable-WSManTrace
Get-LogProperties            Get-LogProperties
Set-LogProperties            Set-LogProperties
Start-Trace                  Start-Trace
Stop-Trace                   Stop-Trace

PS> gcm -Module PSDiagnostics

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Function        Disable-PSTrace                                    6.1.0.0    PSDiagnostics
Function        Enable-PSTrace                                     6.1.0.0    PSDiagnostics
Function        Get-LogProperties                                  6.1.0.0    PSDiagnostics
Function        Set-LogProperties                                  6.1.0.0    PSDiagnostics

Expected behavior

The module should export all cmdlets that are compatible with the version of the OS that is running.

Actual behavior

The module does not export the cmdlets that require logman.exe.

PSDiagnostics.psm1 contains the following code:

if ($psedition -eq 'Core')
{
    # Currently we only support these cmdlets as logman.exe is not working on Nano/Lot system.
    Export-ModuleMember Enable-PSTrace, Disable-PSTrace, Get-LogProperties, Set-LogProperties
}
else
{
    Export-ModuleMember Start-Trace, Stop-Trace, Enable-WSManTrace, Disable-WSManTrace, Enable-PSTrace, Disable-PSTrace, Enable-PSWSManCombinedTrace, Disable-PSWSManCombinedTrace, Get-LogProperties, Set-LogProperties
}

Prior to PSv6 $PSEdition -eq 'Core' meant that you were running on a system that did not have logman.exe. With the release of PSv6 $PSEdition applies more to PowerShell and not to OS. We should use the Win32_OperatingSystem OperatingSystemSKU property to identify non-Core/non-Nano/non-IoT versions of Windows.

Environment data

PS> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      6.1.1
PSEdition                      Core
GitCommitId                    6.1.1
OS                             Microsoft Windows 10.0.17134
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Activity

  1. iSazonov commented on Nov 29, 2018

    @iSazonov
    Collaborator

    Paul Higinbotham (@PaulHigin) Steve Lee (@SteveL-MSFT) Can you confirm the suggested solution?

  2. added
    Issue-Bug
    WG-Cmdlets
    on Nov 29, 2018
  3. SteveL-MSFT commented on Nov 30, 2018

    @SteveL-MSFT
    Member

    What Sean Wheeler (@sdwheeler) says is correct, if those cmdlets depend on logman.exe, perhaps the detection logic should just see if that exe is in the path (use Get-Command)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Issue-BugResolution-FixedWG-Cmdlets

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions