Search multiple servers in powershell to find if it has a certificate thumbprint

Ak 1 Reputation point
2022-10-16T14:22:44.07+00:00

I am looking for a script to query a list of servers to find which ones have a specific certificate (Using the thumbprint)

1 - Input is a list of servers in a txt file
2 - Query loops through the list of servers
3 - returns the servers that has the certificate in a text file

Windows Server Security
Windows Server Security
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.Security: The precautions taken to guard against crime, attack, sabotage, espionage, or another threat.
1,737 questions
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,399 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Rich Matheisen 45,111 Reputation points
    2022-10-17T01:49:57.75+00:00

    Try something like this:

    $Thumbprint = '838A1C18C19XXBOGUSXX47CC21071A0F220617466'  
    $cn = Get-ADComputer -Filter * | Select-Object -ExpandProperty Name  
    Invoke-Command -ComputerName $cn -ScriptBlock{  
        Get-ChildItem -path Cert:\* -Recurse |  
            Where-Object $_.Thumbprint -eq $Using.$ThumbPrint |  
                Select-Object @{n='Computer';e={$ENV:ComputerName}}, Thumbprint, Friendlyname  
    }  
    
    0 comments No comments