Search code examples
powershellpowershell-modulesubsystem

`Get-PSSubsystem` is not recognized


PS C:\> Get-PSSubsystem causes error

Get-PSSubsystem: The term 'Get-PSSubsystem' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

According to the docs, Get-PSSubsystem is part of of the Microsoft.PowerShell.Core module and said module can't be installed?

The Microsoft.PowerShell.Core snap-in contains cmdlets and providers that manage the basic features of PowerShell. PowerShell loads Microsoft.PowerShell.Core snap-in automatically at startup. This is not a module. You can't import it using Import-Module or remove it using Remove-Module.

quote source


Did Get-Module Microsoft.PowerShell.Core -ListAvailable and got no output.

Tried another of Microsoft.PowerShell.Core's commands (Add-History) and did not get an error.

Output of Get-Help Subsystem | Select Name

Name
----
New-StorageSubsystemVirtualDisk
Set-StorageSubSystem
Debug-StorageSubSystem
Unregister-StorageSubsystem
Register-StorageSubsystem
Get-StorageSubSystem

`Get-Command | sls Subsystem" outputted the same list (but in different order).


If it's relevant, here's the output of $PSVersionTable

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

Solution

  • Get-PSSubsystem

    is an experimental Cmdlet:

    Note

    This is an experimental feature. This cmdlet is only available when the PSSubsystemPluginModel feature is enabled. For more information, see Using Experimental Features.

    This means that the Get-PSSubsystem is not (yet) available in the current PowerShell version 7.4.5 but it is available in PowerShell.Preview version 7.5.0.4.

    You might install this preview version with the command:

    winget install --id Microsoft.Powershell.Preview --source winget
    

    And once you installed it, you might able to use that preview version from e.g. Windows - Start or launching it from the command line:

    "C:\Program Files\PowerShell\7-preview\pwsh.exe" -WorkingDirectory ~
    PowerShell 7.5.0-preview.4
    
    $PSVersionTable
    
    Name                           Value
    ----                           -----
    PSVersion                      7.5.0-preview.4
    PSEdition                      Core
    GitCommitId                    7.5.0-preview.4
    OS                             Microsoft Windows 10.0.19045
    Platform                       Win32NT
    PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
    PSRemotingProtocolVersion      2.3
    SerializationVersion           1.1.0.1
    WSManStackVersion              3.0
    
    PS C:\> Get-PSSubsystem -?
    
    NAME
        Get-PSSubsystem
    
    SYNTAX
        Get-PSSubsystem [<CommonParameters>]
    
        Get-PSSubsystem -Kind {CommandPredictor | CrossPlatformDsc | FeedbackProvider} [<CommonParameters>]
    
        Get-PSSubsystem -SubsystemType <type> [<CommonParameters>]
    
    ...
    

    ⚠️ Caution

    Experimental features aren't intended to be used in production since the changes are allowed to be breaking. Experimental features aren't officially supported. However, we appreciate any feedback and bug reports. You can file issues in the GitHub source repository.