ps/Modules/Alkami.DevOps.Inventory/Private/Add-CertificatesToInventoryDictionary.ps1
2023-05-30 22:51:22 -07:00

33 lines
904 B
PowerShell

function Add-CertificatesToInventoryDictionary {
<#
.SYNOPSIS
Adds Certificates to the Inventory Dictionary.
#>
[CmdletBinding()]
param(
[Parameter(Mandatory = $true)]
[Object[]]$certificates
)
$logLead = (Get-LogLeadName);
$dictionary = New-Object System.Collections.Specialized.OrderedDictionary
foreach ($cert in $certificates | Group-Object {$_.Thumbprint}) {
$uniqueCert = $cert.Group | Select-Object -First 1
$certPropertyHash = Get-CertificatePropertyHash $uniqueCert
if ($cert.Count -gt 1) {
$thumbprint = $uniqueCert.Thumbprint
Write-Warning "$logLead : Certificate With Thumbprint $thumbprint Has a Duplicate Record"
$certPropertyHash.Add("HasDuplicate", $true)
}
$dictionary.Add($uniqueCert.Thumbprint.ToString(), $certPropertyHash)
}
return $dictionary
}