2013-11-25 2 views
-1

저는 재해 복구 프로젝트를 진행하고 있으며 기본 및 보조 사이트에 대한 정기 감사 계획의 일환으로 권장하고 있습니다. 감사 작업 중 하나는 보조 사이트에 기본 사이트와 동일한 인증서가 설치되어 있는지 확인하는 것입니다. 나는 내가 내가 인증서 표시 목록하지만 나는 모두 하나의 스크립트에서이 작업을 수행하려고에 문제가있어를 얻기 위해 위의 명령을 사용할 수 있습니다 알고이 사용하는 파워 쉘Powershell을 사용하여 인증서 비교

Get-ChildItem -Path Cert:\LocalMachine\My 
Get-ChildItem -Path Cert:\LocalMachine\Root 

을 수행 할 수 있다고 생각합니다. 한 서버에서 certs 목록을 얻은 다음 다른 서버에서 certs 목록을 가져 와서 두 목록을 비교하고 싶습니다. Powershell을 처음 접했을 때 나는 어디서부터 시작해야할지 모르겠다.

+3

당신이 시도 무엇을, 어떤 문제가 당신이 도움을 필요가 발생 했습니까? –

+0

위의 명령을 사용하여 certs 목록을 얻을 수 있지만 문제가있는 것은 하나의 스크립트에서이 모든 작업을 시도하는 것입니다. 한 서버에서 certs 목록을 얻은 다음 다른 서버에서 certs 목록을 가져 와서 두 목록을 비교하고 싶습니다. Powershell을 처음 접했을 때 나는 어디서부터 시작해야할지 모르겠다. – tdean

+1

시작 [여기] (http://blogs.msdn.com/b/timid/archive/2009/10/07/powershell-for-non-n00bs-certificates-installed-on-a-remote-host.aspx) . –

답변

2

인증서를 검색하려면 기본적으로 인증서 공급자가 원격 컴퓨터 연결을 노출하지 않으므로 기본 .NET 클래스를 사용합니다. 추신 : PS 리모팅으로 다른 가능성을 발견 할 수도 있습니다. 여기에 기능입니다 :

function Get-Certificates { 
    Param(
      $Computer = $env:COMPUTERNAME, 
      [System.Security.Cryptography.X509Certificates.StoreLocation]$StoreLocation, 
      [System.Security.Cryptography.X509Certificates.StoreName]$StoreName 
     ) 

    $Store = New-Object System.Security.Cryptography.X509Certificates.X509Store("\\$computer\$StoreName",$StoreLocation) 
    $Store.Open([System.Security.Cryptography.X509Certificates.OpenFlags]"ReadOnly") 
    $Store.Certificates 
} 

그리고 여기에 두 개의 목록을 비교하는 데 사용하는 것이 방법입니다

$Left = Get-Certificates -StoreLocation LocalMachine -StoreName Root 
$Right = Get-Certificates -StoreLocation LocalMachine -StoreName Root -Computer "REMOTE-PC" 

# Dump to console 
Compare-Object $Left $Right -property Thumbprint, FriendlyName, Subject, NotAfter | Format-Table 

# Export results to file 
Compare-Object $Left $Right -property Thumbprint, FriendlyName, Subject, NotAfter | Export-Csv Comparison.csv 
관련 문제