Skip to content

PSDiagnostics does not properly export all cmdlets in PSv6 #8339

@sdwheeler

Description

@sdwheeler

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

Metadata

Metadata

Assignees

Labels

Issue-BugIssue has been identified as a bug in the productResolution-FixedThe issue is fixed.WG-Cmdletsgeneral cmdlet issues

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions