透過 PowerShell 檢查 Windows 證書過期日期的方法有哪些?
若要從指定儲存中獲取特定 Windows 證書的過期日期,我們首先需要該證書的完整路徑和指紋。如果您不知道指紋,則可以使用友好名稱。
使用指紋,
Get-ChildItem Cert:\LocalMachine\root\0563B8630D62D75 | fl *
執行上述命令後,它將獲取指紋為 0563B8630D62D75 的證書的所有詳細資訊。
您可以在此處看到列出了兩個欄位,NotAfter 和 NotBefore,它們分別顯示了逾期日期和開始日期。若要過濾它們,
示例
Get-ChildItem Cert:\LocalMachine\root\0563B8630D62D75 | Select FriendlyName, NotAfter,NotBefore
輸出
FriendlyName NotAfter NotBefore ------------ -------- --------- DigiCert 11/9/2031 4:00:00 PM 11/9/2006 4:00:00 PM
使用 FriendlyName 屬性,
Get-ChildItem Cert:\LocalMachine\root\ | where{$_.FriendlyName -eq “DigiCert”} | Select FriendlyName, NotAfter,NotBefore
若要從遠端計算機獲取詳細資訊,請使用 Invoke-Command。
Invoke-Command -ComputerName Test1PC, Test2PC -ScriptBlock { Get-ChildItem Cert:\LocalMachine\root\ | where{$_.FriendlyName -eq “DigiCert”} | Select FriendlyName, NotAfter,NotBefore }
廣告