Skip to content

Instantly share code, notes, and snippets.

@mczerniawski
Created September 3, 2018 19:47
Show Gist options
  • Select an option

  • Save mczerniawski/0c93c9e0cab1c629c6785e4def0517d3 to your computer and use it in GitHub Desktop.

Select an option

Save mczerniawski/0c93c9e0cab1c629c6785e4def0517d3 to your computer and use it in GitHub Desktop.
$Computers = Get-ADComputer -filter * -SearchBase 'OU=Servers,OU=ComputersX,DC=contoso,DC=com' | Select-Object -ExpandProperty Name
$Allcerts = Invoke-Command -ComputerName $Computers -ScriptBlock {
Get-childItem Cert:\LocalMachine\My | Select-Object DnsNameList,NotBefore,NotAfter,Thumbprint,Issuer,Subject
} -ErrorAction SilentlyContinue
#region get the cert we're looking for
$thumbprint = 'PLACEYOURTHUMBPRINTHERE'
$CurrentCert = $Allcerts | Where-Object {$_.Thumbprint -eq $thumbprint} | Select-Object PSComputerName
$CurrentCert | Export-Csv -Path C:\AdminTools\CurrentCert.csv -NoTypeInformation -Delimiter ';'
#endregion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment