windows - 使用 PowerShell 重置 'Friendly Name' 证书属性

标签 windows powershell certificate

我需要一个证书的Friendly Name在证书控制台中设置为空值 Friendly Name列将显示 <None> . 使用此代码我所能得到的只是列中的空值,而不是 <None>我需要。

 gci "Cert:\LocalMachine\My" | ? {$_.Subject -like "CN=mycer*"} | % { $_.FriendlyName = '' }

我也试过$_.FriendlyName = $null这没有什么区别。

奇怪的事情 - 当我清除 Friendly Name使用控制台,然后从 Powershell 的角度来看,该值为 ''因为以下语句会产生 True : write-host ($_.FriendlyName -eq '') .然而,'' ' 反之亦然应用的值未提供预期的结果。

非常感谢任何帮助。

更新和回答: 作为Kory Gill在评论中建议,certutil.exe 确实是获得我需要的东西的方法。 创建了一个 clear.inf文件内容如下

[Version]
Signature = "$Windows NT$"

[Properties]
11 = 

并执行certutil.exe -repairstore -user my "serial number" clear.inf我设法重置了 Friendly Name<None>值(value)。

最佳答案

作为管理证书的 PowerShell cmdlet 的替代品,它可能与某些属性有关,也可以使用 certutil.exe 来管理证书。这类似于使用 robocopy.exe 而不是 Copy-File。使用能为您带来预期结果的工具...

This link显示了如何使用 certutil 更改友好名称的示例。

该页面的示例用法是:

certutil.exe -repairstore my "{serialnumber}" "change-friendly-name.inf"

inf 文件的样子:

[Version]
Signature = "$Windows NT$"
[Properties]
11 = "{text}new friendly name"

另见 certutil reference .

关于windows - 使用 PowerShell 重置 'Friendly Name' 证书属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49633570/

相关文章:

windows - cmd.exe 返回 "Not enough storage is available to process this command."

windows - 检测键盘或鼠标事件是否由软件触发

java - 通过 Java 查询 Active Directory

windows - 查明进程是否正在 cmd.exe 或 PowerShell 窗口中运行

delphi - 如何获取 CDO.Message 的错误代码

.net - X509Certificate2 使 IIS 崩溃

windows - 如何使用特定用户的命令行在Windows中查看文件夹权限?

python - 如何从扩展名为 .pyw 的 Python 脚本打印到标准输出?

PowerShellscript,错误的文件编码对话

java - 将证书与 https url 相关联