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

时间:2018-08-21 18:16:08

标签: powershell windows-10 certificate powershell-v5.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...

这是我运行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}

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

2 个答案:

答案 0 :(得分:2)

我发现了同样的问题。

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

答案 1 :(得分:0)

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

$env:PSModulePath = [Environment]::GetEnvironmentVariable('PSModulePath', 'Machine')