User Tools

Site Tools


powershell_cheat_sheet

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
powershell_cheat_sheet [2021/02/18 06:54] – [Get Install-Module working behind a webproxy] stephenpowershell_cheat_sheet [2021/04/13 21:53] (current) – external edit 127.0.0.1
Line 59: Line 59:
 </code> </code>
  
-===== Search installed certs for thumbprint =====+===== Certificates ===== 
 + 
 +Search by thumbprint:
  
 <code powershell> <code powershell>
Line 69: Line 71:
 <code powershell> <code powershell>
 Get-ChildItem -Path Cert: -Recurse | Where-Object { $_.Thumbprint -and $_.Thumbprint.ToLower().StartsWith('c4') } | Test-Certificate Get-ChildItem -Path Cert: -Recurse | Where-Object { $_.Thumbprint -and $_.Thumbprint.ToLower().StartsWith('c4') } | Test-Certificate
 +</code>
 +
 +To check for expired / revoked certs:
 +
 +<code powershell>
 +$certs = Get-ChildItem -Path Cert:\LocalMachine\My -Recurse
 +foreach ($cert in $certs) {
 +    Write-Host "$($cert.Thumbprint) $($cert.Subject)"
 + 
 +    if ($certs.NotAfter -lt (Get-Date)) {
 +        Write-Host "    Expired on $($certs.NotAfter)" -ForegroundColor Red
 +    }
 +    elseif ($cert | Test-Certificate) {
 +        Write-Host "    Tested ok." -ForegroundColor Green
 +    }
 +}
 </code> </code>
  
powershell_cheat_sheet.1613631243.txt.gz · Last modified: 2021/02/19 07:54 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki