无法通过 Powershell 找到证书:驱动器或证书提供者

Car*_*ton 5 powershell certificate windows-10 powershell-5.0

出于某种原因,我安装的 Windows 10/Powershell 5.0 似乎缺少Certificate Provider。似乎我什至没有Microsoft.PowerShell.Security模块,该模块默认情况下应该与 powershell 一起安装并包含证书提供程序。这是我运行 Get-Module 时得到的结果(我之前添加了 post-git,也许我这样做时搞砸了?):

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Manifest   3.1.0.0    Microsoft.PowerShell.Management     {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Con...
Manifest   3.1.0.0    Microsoft.PowerShell.Utility        {Add-Member, Add-Type, Clear-Variable, Compare-Object...}
Script     0.7.1      posh-git                            {Add-PoshGitToProfile, Add-SshKey, Enable-GitColors, Get-A...
Script     1.2        PSReadline                          {Get-PSReadlineKeyHandler, Get-PSReadlineOption, Remove-PS...
Run Code Online (Sandbox Code Playgroud)

这是我运行 Get-PSProvider 时得到的结果:

Name                 Capabilities                                      Drives
----                 ------------                                      ------
Registry             ShouldProcess, Transactions                       {HKLM, HKCU}
Alias                ShouldProcess                                     {Alias}
Environment          ShouldProcess                                     {Env}
FileSystem           Filter, ShouldProcess, Credentials                {C, D, E}
Function             ShouldProcess                                     {Function}
Variable             ShouldProcess                                     {Variable}
Run Code Online (Sandbox Code Playgroud)

无论如何,我可以重新安装 PowerShell 或将此提供程序/驱动器添加到我的构建中,而无需完全重新安装 Windows?我的机器似乎发生了一些非常可疑的事情,如果不是绝对必要的话,我真的宁愿不完全重新安装。

Ete*_*l21 5

在 MSI 安装期间运行自定义 powershell 操作时,我遇到了同样的错误。Maco1717的回答为我指明了正确的方向。事实证明,当 Powershell 在安装程序上下文中运行时,PSModulePath 是不同的。修复方法是在脚本开头从环境变量加载正确的路径,如下所示:

$env:PSModulePath = [Environment]::GetEnvironmentVariable('PSModulePath', 'Machine')
Run Code Online (Sandbox Code Playgroud)

  • 工作起来就像一个魅力,虽然我不完全知道为什么“PSModulePath”被搞乱了! (2认同)

mac*_*717 2

我来发现同样的问题。

我的情况是,问题是 PSModulePath 环境变量中没有正确的路径。