Cer文件是一段包含base64证书内容的字符串,用记事本打开,可能是这样:
-----BEGIN CERTIFICATE----- MIIGPTCCBCWgAwIBAgITWgACJS12PP6tbgIWkQABAAIlLTANBgkqhkiG9w0BAQsF ..... V4i3CeXHNPjD9orej/BVT2TcD9zfMckjpxDMZ+Pk1N73IpVgsgZEPJWss5Ck2z94 Bom9cGbG1oO92bnaZRbcUm4= -----END CERTIFICATE-----
今天写一个函数,可以将有效的
# # # Example: Get-DataFromCerFile D:\data\cert\pstips.net.cer # Function Get-DataFromCerFile { param($CerFile) if( -not (Test-Path $CerFile)) { Write-Error "$CerFile 文件不存在." } elseif($CerFile -notlike '*.cer') { Write-Error "只支持Cert文件." } $rawFile = New-Object System.IO.FileInfo (Resolve-Path $CerFile).Path $certValueFile = "$rawFile.data.txt" $rawData = Get-Content $CerFile | Where-Object { ($_ -notmatch '-') -and (-not ([string]::IsNullOrWhiteSpace($_.ToString().Trim()))) } $rawData -join '' | clip.exe Write-Host "证书内容以保存到剪贴板." -ForegroundColor Green }
本文链接: https://www.pstips.net/copy-certificate-value-from-cer-file.html
请尊重原作者和编辑的辛勤劳动,欢迎转载,并注明出处!
请尊重原作者和编辑的辛勤劳动,欢迎转载,并注明出处!