-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
Steps to reproduce
- Install PowerShell 7.4.1 on Windows
- Attempt to use
pwsh -commandto use the PKI module (for example> pwsh -c "Import-Module PKI")
Note that the import works fine when run directly (> Import-Module PKI). pwsh -c "Import-Module PKI" also works fine in PowerShell 7.3.1. I was able to reproduce the same behavior in an Azure DevOps pipeline as well (not public), so I don't think it has to do with my machine.
I was able to work around this by setting the $env:PSModulePath = [Environment]::GetEnvironmentVariable('PSModulePath', 'Machine'), like
pwsh -c { $env:PSModulePath = [Environment]::GetEnvironmentVariable('PSModulePath', 'Machine') ; Import-Module PKI }
I realize PKI is a Windows PowerShell module, but the above scenario was working in PowerShell Core until 7.4.1.
Expected behavior
PS> pwsh -c "Import-Module PKI"
* silently succeeds, just like when running:
PS> Import-Module PKI
Actual behavior
PS> pwsh -c "Import-Module PKI"
Import-Module: The module to process 'Microsoft.CertificateServices.PKIClient.Cmdlets', listed in field 'NestedModules' of module manifest 'C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\PKI\PKI.psd1' was not processed because no valid module was found in any module directory.
Error details
no output
Environment data
Name Value
PSVersion 7.4.1
PSEdition Core
GitCommitId 7.4.1
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
