使用 PowerShell 更新多个证书友好名称

Update multiple Certificate friendly names using PowerShell

我是 PowerShell 的新手,目前我正在使用 PowerShell 远程更新大量证书友好名称。

我已经完成了下面的脚本,如果有一个证书,它可以正常工作,但如果商店中有多个证书,它就会失败,因为我需要在脚本中添加一个循环。当我尝试在其中添加循环时,它似乎不起作用。有人可以帮助我或指出正确的方向吗?

输入-PSSession –ComputerName 服务器名

Get-ChildItem -Path Cert:\LocalMachine\My
$CertStore = "Cert:\LocalMachine\My\"
$FriendlyName = 'Examplename'
$cert = Get-ChildItem $CertStore
$cert.FriendlyName = $FriendlyName

感谢您的帮助。

只需在脚本中添加一个 Foreach 循环。 如下所示:

$CertStore = "Cert:\LocalMachine\My\"
$FriendlyName = 'Examplename'
$cert = Get-ChildItem $CertStore | foreach {$_.FriendlyName = $FriendlyName}

这将更新多个具有友好名称的证书。