Search code examples
powershellcertificate

Update multiple Certificate friendly names using PowerShell


I am fairly new to PowerShell and I am currently updating a large list of Certificate Friendly names remotely using PowerShell.

I have done the below script which works fine if there is one certificate but it fails if there is multiple certificates in the store as I need to add a Loop into the script. When I am trying to add a loop in it doesn't seem to be working. Could someone help or point me in the right direction please?

Enter-PSSession –ComputerName Servername

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

Thanks for any help.


Solution

  • Just add a Foreach Loop into the script. Something like below:

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

    And this will update multiple Certificates with friendly names.