Powershell查询域中的计算机并获取证书值

我们正在查看环境中所有计算机的列表,并查看计算机上有哪些证书。 我们需要知道他们是sha1还是sha2哈希。

我在网上查找,不能看到这是甚至可能的?

请帮助

你可以像这样检查algorithm:

$Cert = Get-ChildItem Cert:\LocalMachine\My\ | Select -First 1 if($Cert.SignatureAlgorithm.FriendlyName -like "sha2*"){ Write-Host "SHA2 sig, all good" } 

要获取域中的所有计算机,只需使用Get-ADComputer

 $Computers = Get-ADComputer -Filter {Enabled -eq $True} foreach($Computer in $Computers){ # Run your check against each $Computer in here } 

然后,您可以使用PSRemoting,并在远程计算机上执行检查:

 $pss = New-PSSession -ComputerName remotemachine.domain.tld Invoke-Command -Session $pss -ScriptBlock { # code to check certs go here } 

或者,您可以直接连接到您自己的机器上的远程证书存储:

 $CertStore = New-Object System.Security.Cryptography.X509Certificates.X509Store "\\$ComputerName\My","LocalMachine" $CertStore.Open([System.Security.Cryptography.X509Certificates.OpenFlags]::ReadOnly) foreach($Cert in $CertStore.Certificates){ # once again, inspect $Cert.SignatureAlgorithm } $CertStore.Close()