Created
September 3, 2018 19:49
-
-
Save mczerniawski/bc9801b831c9f3eea1cdbf5a9d642129 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$Computers = Get-ADComputer -filter * -SearchBase 'OU=Servers,OU=ComputersX,DC=contoso,DC=com' | Select-Object -ExpandProperty Name | |
$Allcerts = Invoke-Command -ComputerName $Computers -ScriptBlock { | |
Get-childItem Cert:\LocalMachine\My | Select-Object DnsNameList,NotBefore,NotAfter,Thumbprint,Issuer,Subject | |
} -ErrorAction SilentlyContinue | |
#region get all certs that expired | |
#get current date | |
$date = Get-Date | |
$ExpiredCerts = $Allcerts | Where-Object {$PSItem.NotAfter -le $date} | Select-Object DnsNameList,NotBefore,NotAfter,Thumbprint,Issuer,Subject,PSComputerName | |
$ExpiredCerts | Export-Csv -Path C:\AdminTools\ExpiredCerts.csv -NoTypeInformation -Delimiter ';' | |
#endregion |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment