$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:/
尝试使用前向斜线而不是后斜线。
您是作为管理员执行的吗?