c# - PowerShell 通过远程注册表获取证书

标签 c# powershell ssl certificate remote-registry

$Srv ='10.101.22.82' #remote server
$key = "SOFTWARE\\Microsoft\\SystemCertificates\\MY\\Certificates"
$type = [Microsoft.Win32.RegistryHive]::LocalMachine
$regKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey($type, $Srv)
$regKey = $regKey.OpenSubKey($key)
Write-Host "Sub Keys"
Write-Host "--------"
Foreach($sub in $regKey.GetSubKeyNames())
{
 #open the subkey here and parse the contents
 $myStr = "SOFTWARE\\Microsoft\\SystemCertificates\\MY\\Certificates\\"+$sub
 $regKey2 = $regKey.OpenSubKey($myStr)
 $bytes = $regKey2.GetValue($sub).Blob
 echo $bytes
 $cert = [System.Security.Cryptography.X509Certificates.X509Certificate2]$bytes
 $cert | Select Subject, Issuer, NotBefore, NotAfter, Thumbprint, SerialNumber
} 

我正在尝试使用 PowerShell 读取远程注册表并获取 SSL 证书。我错过了什么?不胜感激,谢谢

最佳答案

您是否在您查询的远程主机上启用了远程处理?如果是这样,像

Invoke-Command -Computername COMPUTER -ScriptBlock {Get-ChildItem Cert:\LocalMachine\My}

会干净很多。

关于c# - PowerShell 通过远程注册表获取证书,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26528884/

相关文章:

Spring 启动 : Not to use TLSv1. 0

c# - 刷新下拉列表但保留旧的选定值 JSON

c# - Emgu 相机校准

c# - Web 服务中的数据库访问

PowerShell:模块、它们的位置和重新加载

java - 在 Java 客户端中使用 SNI 的 TLS

c# - 在Google Play商店中提交 “500 No individual errors”的原因

powershell - 将批处理脚本转换为Powershell脚本

powershell - PowerShell 中的特殊字符

javascript - SSL & JQuery = 没有挂锁/为什么?