x509certificate2.Import无法在当前文件夹下找到文件


$localPfx = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2
$localPfx.Import(".myCert.pfx", "password", "Exportable,PersistKeySet")

我有

Exception calling "Import" with "3" argument(s): "The system cannot find the file specified.

如果我使用

$PfxFileFull = Convert-Path .myCert.pfx

$PfxFileFull = "D:...myCert.pfx" #full path

然后运行

$localPfx.Import($PfxFileFull, "password", "Exportable,PersistKeySet")

然后例外消失了。

为什么会发生?

相信系统。由于某种原因,它找不到文件。确保正确设置所有内容,这就是系统的工作方式。

尝试将其复制到C:/

尝试使用前向斜线而不是后斜线。

您是作为管理员执行的吗?

最新更新