Skip to content

Commit 3c3b7ec

Browse files
committed
draft of enabling discover of compatible Windows PowerShell modules in PowerShell Core 6
1 parent 73d3ceb commit 3c3b7ec

File tree

1 file changed

+81
-0
lines changed

1 file changed

+81
-0
lines changed
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
---
2+
RFC: RFCNNNN
3+
Author: Steve Lee
4+
Status: Draft
5+
SupercededBy: n/a
6+
Version: 0.1
7+
Area: Engine
8+
Comments Due: 6/30
9+
Plan to implement: Yes
10+
---
11+
12+
# Enable Discovery and Importing of Compatible in-box Windows PowerShell modules
13+
14+
The biggest factor preventing existing Windows PowerShell users from moving to PowerShell Core 6 has been cmdlet coverage.
15+
Specifically being able to use existing cmdlets that ship with Windows.
16+
The PowerShell team has been working with Windows teams to port their modules so that they work in PowerShell Core 6.
17+
This RFC addresses the experience for the user when using PowerShell Core 6.1 with next version of Windows 10.
18+
19+
## Motivation
20+
21+
As a ITPro,
22+
I can use existing Windows PowerShell modules in PowerShell Core 6,
23+
so that I can start deploying PowerShell Core 6 in my enterprise.
24+
25+
## Specification
26+
27+
The module manifest (since Windows PowerShell 5) may contain a `CompatiblePSEditions` property to indicate if it is compatible with
28+
Windows PowerShell (value of `Desktop` even on Windows Server) or PowerShell Core (value of `Core`).
29+
Currently, this property is only documentation and not observed by PowerShell.
30+
The proposal is to modify PowerShell Core 6.1 to respect this property.
31+
32+
### Windows PSModulePath
33+
34+
Windows PowerShell, by default, has module paths in:
35+
36+
1. User profile: $env:UserProfile\Documents\WindowsPowerShell\Modules
37+
2. Program files: $env:ProgramFiles\WindowsPowerShell\Modules
38+
3. System32: $env:Windir\System32\WindowsPowerShell\v1.0\Modules
39+
40+
The proposed change is to add *only* the `System32` path to `PSModulePath` on PowerShell Core 6.
41+
42+
Modules in the user profile should be re-installed under PowerShell Core 6.
43+
Duplicate modules is something that can be addressed in PowerShellGet and outside the scope of this RFC.
44+
Modules in `Program Files` that may be compatible with PowerShell Core 6 is addressed below.
45+
46+
Users who want to search the entirety of the Windows PowerShell PSModulePath should use `Add-WindowsPSModulePath` cmdlet
47+
from the `WindowsCompatibility` module.
48+
49+
### PowerShell Core PSModulePath
50+
51+
Modules in the PowerShell Core PSModulePaths are implicitly deemed compatible even if the manifest does not
52+
declare compatibility.
53+
A user would have explicitly used `Install-Module` within PowerShell Core 6 for those modules to be in the
54+
PowerShell Core 6 module path with expectation those modules are available.
55+
56+
### CompatiblePSEditions
57+
58+
If the module manifest contains `CompatiblePSEditions` with value `Core`, then that module is treated as compatible.
59+
If the module manifest contains `CompatiblePSEditions` with only the value of `Desktop`, then that module is treated as incompatible.
60+
If the module manifest does not contain `CompatiblePSEditions`, then that module is treated the same as `Desktop` which is incompatible.
61+
62+
By default, `Get-Module -ListAvailable` will only show modules found in `PSModulePath` that are declared as compatible.
63+
Similarly, module auto-discovery will only find modules that are declared as compatible.
64+
65+
The `ModuleInfo` table format will add a column for `CompatiblePSEditions` (between `Name` and `ExportedCommands`).
66+
67+
### Using Modules not declared as Compatible
68+
69+
`Get-Module -ListAvailable` will support `-SkipCompatibilityCheck` switch to list all modules in `PSModulePath`.
70+
71+
If `Import-Module` is used with a module that is not declared in the manifest as compatible, it will throw a terminating error:
72+
73+
> The module '{0}' could not be imported as it is not declared as compatible. Use `-SkipCompatibilityCheck` switch to override this check.
74+
75+
`Import-Module` will support `-SkipCompatibilityCheck` switch to try and import the module regardless of `CompatiblePSEditions`.
76+
Since module auto-discovery does not expose cmdlets from modules not declared as compatible, explicit `Import-Module` with
77+
`-SkipCompatibilityCheck` is required to use potentially incompatible modules.
78+
79+
## Alternate Proposals and Considerations
80+
81+
Open issue: Should `CompatiblePSEditions` column only be added in `ModuleInfo` table format if used with `-SkipCompatibilityCheck`?

0 commit comments

Comments
 (0)