Files
Backup/_NDGOV_WindowsTeam/ITD.Infra-Servers-PowerShellUniversal.Production/Infra-Certificate-External.Sectigo/Unregister-CommonName.ps1
T
Zack Meier 1d304511b8 update
2026-04-15 15:45:50 -05:00

28 lines
801 B
PowerShell

[CmdletBinding()]
param (
[Parameter(Mandatory = $true,
HelpMessage = "Common Name for cert")]
[string]
$CommonName
)
Import-Module ITD.Infra-Certificate-External.JsonDB
Write-Verbose -Verbose "Set DB Environment"
Set-JDEnvironment -Name prod
$PreviousThumbprint=(Select-JDJson -TableName certcache -CommonName $commonname).Thumbprint
#Unreg from cert log
if ($PreviousThumbprint) {
$table=@("certlog")
Foreach ($t in $table) {
Set-JDJson -TableName $t `
-Where { param($row) $row.CommonName -eq $commonname } `
-Set @{ is_retired = $true; PreviousThumbprint = 'OLD-000-XYZ' } `
-Verbose
} #end of foreach
} #end of if $Previous thumbprint
#delete from certcache
Remove-JDJson -TableName certcache -Where { param($o) $o.commonname -eq $commonname }