You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
CertificateProvider auto-imports PKI module many times #11241
Attempting to use the PKI Module in Win10 using Preview 6.
I kind of expect a warning when the module is first loaded, with either import-module or via module autoload. But not on every operation:
See this graphic:
In this session, I Set-Location (getting a warning), then did a get-ChildItem (and got a second warning message) then I did another Get-ChildItem (and got a THIRD warning. All the commands sent to the provider seem to generate a warning and I'd argue this is not a good user experience.
Steps to reproduce
# 1. Open a PowerShell console window then type:
CD Cert:\
LS
LS .\Currentuser
Expected behaviour
I would not expect the second two (and all subsequent) uses of cmdlets in a compatibility-imported module. I can live with the first warning, but the rest are a poor user experience.
Actual behaviour
See the graphic above
Environment data
PS Cert:\> $PSVersionTable
Name Value
---- -----
PSVersion 7.0.0-preview.6
PSEdition Core
GitCommitId 7.0.0-preview.6
OS Microsoft Windows 10.0.18363
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Thomas Lee (@doctordns) In reviewing this I also noticed that any use of tab completion for any cmdlet (not parameters) seems to produce the warning at the moment the tab key is pressed, then completion options are shown after the warning message.
Get- produces the warning
Get-Process - Does not produce warning
Short version: This looks like a manifestation of a bug in CertificateProvider - loading pki module on every operation with a certificate path. Wincompat's warning just made this visible.
Thomas Lee (@doctordns) In reviewing this I also noticed that any use of tab completion for any cmdlet (not parameters) seems to produce the warning at the moment the tab key is pressed, then completion options are shown after the warning message.
I've been seeing this with particular module I have been working with (or I might say has been working against me) dynamic parameters seem to be expanded as part of get-command and the tab completion seems to cause the dynamicParam code to run. I found if I set $verbosePrefernce to Continue, tab expanding a command generated hundreds of lines of verbose output because the module in question had 60+ dynamic params, each of which did significant work.
I suspect something similar is going on here.
On a side note, a single PS Cert:> Get-ChildItem call ends up invoking CertificateProvider constructor 19 (!) times at various stages.
I guess it is in LocationGlobber. It unify entry points to providers but this causes performance problems. It calls helper methods repeatedly many times. We have a tracking issue for FileSystem provider v2 and looking this I think we needs to change design and make entry points in base provider class to preserve unification and get high performance.
Thomas Lee (@doctordns)#11259 will remove excessive warnings that you're observing. Functionality-wise commands of PKI module will continue to behave like they currently are. If they support serialization - they should work fine - this is basically a general rule for any module that is loaded through WinCompat.
This issue is good for tracking a multi-import of PKI module bug in CertificateProvider/LocationGlobber boundary. This should be fixed.
changed the title [-]PowerShell 7 P6 - PKI Modules Over issues warning due to compatibility[/-][+]CertificateProvider auto-imports PKI module many times[/+]on Dec 20, 2019
Activity
theJasonHelmick commentedon Dec 3, 2019
Thomas Lee (@doctordns) In reviewing this I also noticed that any use of tab completion for any cmdlet (not parameters) seems to produce the warning at the moment the tab key is pressed, then completion options are shown after the warning message.
Get- produces the warning
Get-Process - Does not produce warning
SeeminglyScience commentedon Dec 3, 2019
Also writes warnings in VSCode's integrated console when intellisense hits the same commands.
doctordns commentedon Dec 3, 2019
Jason Helmick (@theJasonHelmick) and Patrick Meinecke (@SeeminglyScience) Yes indeed. It does get worse! It messes IntelliSense as Patrick noticed. To amplify Jason's point...
If I type:
I see this:
This can not be acceptable. :-(
vexx32 commentedon Dec 3, 2019
/cc Steve Lee (@SteveL-MSFT) Andrew (@anmenaga)
anmenaga commentedon Dec 3, 2019
Short version: This looks like a manifestation of a bug in
CertificateProvider- loadingpkimodule on every operation with a certificate path. Wincompat's warning just made this visible.Long version: When creating new items or getting existing certificate items CertificateProvider auto-imports
pkimodule based on it's internal flag_hasAttemptedToLoadPkiModule.This
_hasAttemptedToLoadPkiModuleflag is set tofalseonly once - in CertificateProvider's constructor.However,
SessionStateInternal.GetProviderInstancesimply creates a new instance of the provider every time, therefore resetting_hasAttemptedToLoadPkiModuleflag which subsequently causespkimodule to be re-imported again.Here is the call stack that resets the
_hasAttemptedToLoadPkiModuleflag duringPS Cert:\> lscall:anmenaga commentedon Dec 3, 2019
On a side note, a single
PS Cert:\> Get-ChildItemcall ends up invoking CertificateProvider constructor 19 (!) times at various stages.doctordns commentedon Dec 4, 2019
Andrew (@anmenaga) - thanks for this.
What does this mean for the PKI module? With this P/'R, will these commands work??
And will the CERT: provider work properly (as in act the same as in Windows PowerShell).
jhoneill commentedon Dec 4, 2019
I've been seeing this with particular module I have been working with (or I might say has been working against me) dynamic parameters seem to be expanded as part of get-command and the tab completion seems to cause the dynamicParam code to run. I found if I set $verbosePrefernce to Continue, tab expanding a command generated hundreds of lines of verbose output because the module in question had 60+ dynamic params, each of which did significant work.
I suspect something similar is going on here.
iSazonov commentedon Dec 5, 2019
I guess it is in LocationGlobber. It unify entry points to providers but this causes performance problems. It calls helper methods repeatedly many times. We have a tracking issue for FileSystem provider v2 and looking this I think we needs to change design and make entry points in base provider class to preserve unification and get high performance.
anmenaga commentedon Dec 5, 2019
Thomas Lee (@doctordns) #11259 will remove excessive warnings that you're observing. Functionality-wise commands of PKI module will continue to behave like they currently are. If they support serialization - they should work fine - this is basically a general rule for any module that is loaded through WinCompat.
This issue is good for tracking a multi-import of PKI module bug in
CertificateProvider/LocationGlobberboundary. This should be fixed.[-]PowerShell 7 P6 - PKI Modules Over issues warning due to compatibility[/-][+]CertificateProvider auto-imports PKI module many times[/+]doctordns commentedon Jan 11, 2020
This issue appears to have gone away by RC1. IT now works as expected.