Update multiple Certificate friendly names using powershell

Mike R 81 Reputation points
2021-04-28T16:37:41.87+00:00

Hello,

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?

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

Thanks for any help.

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,381 questions
0 comments No comments
{count} votes

Accepted answer
  1. Ian Xue (Shanghai Wicresoft Co., Ltd.) 29,971 Reputation points Microsoft Vendor
    2021-04-29T03:49:25.423+00:00

    Hi,

    You can use the ForEach-Object cmdlet for looping.

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

    Best Regards,
    Ian Xue

    ============================================

    If the Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful