How-to-simply...

Print SHA256 hash for all RDP server certificates with PowerShell on Windows

  • 1 $certificate.GetCertHash('SHA256')
    $sha256HashHex = [BitConverter]::ToString($sha256Hash)
  • N $certificates = Get-ChildItem -Path 'Cert:\LocalMachine\Remote Desktop'
    if ($certificates.Count -gt 0) {
    $certificateInfo = @()
    foreach ($certificate in $certificates) {
    $rawData = $certificate.RawData
    $sha256 = [System.Security.Cryptograthy.SHA256]::Create()
    $sha256Hash = $certificate.GetCertHash($rawData)
    $sha256HashHex = [BitConverter]::ToString($sha256Hash) -replace '-',''
    $certInfo = New-Object PSObject -Property @{
    'SHA256 Thumbprint' = $sha256HashHex
    'Subject' = $certificate.Subject
    'Issued By' = $certificate.Issuer
    'Expiration Date' = $certificate.NotAfter
    }
    $certificateInfo += $certInfo
    }
    $certificateInfo | Format-Table -AutoSize
    }
    Read-Host -Prompt "`nPress Enter to exit"

References