Skip to content

Instantly share code, notes, and snippets.

@tg12
Created April 15, 2021 08:20
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tg12/83b88ddc71528e4d4dbffd17f7bf5423 to your computer and use it in GitHub Desktop.
Save tg12/83b88ddc71528e4d4dbffd17f7bf5423 to your computer and use it in GitHub Desktop.
Remove all Expired Certs on a Windows Machine
# """THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
# NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR ANYONE
# DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY,
# WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE."""
# Bitcoin Cash (BCH) qpz32c4lg7x7lnk9jg6qg7s4uavdce89myax5v5nuk
# Ether (ETH) - 0x843d3DEC2A4705BD4f45F674F641cE2D0022c9FB
# Litecoin (LTC) - Lfk5y4F7KZa9oRxpazETwjQnHszEPvqPvu
# Bitcoin (BTC) - 34L8qWiQyKr8k4TnHDacfjbaSqQASbBtTd
####################
#This just shows you the expired ones already on your machine.
#Uncomment below to remove expired.
####################
$CertLocations = Get-ChildItem -Path Cert:\LocalMachine\AuthRoot |
? {(Get-Date $_.NotAfter) -le ((Get-Date).AddDays(-7))} |
select Subject, Issuer, NotAfter
Foreach($CertLoc in $CertLocations) {
Write-Host "$CertLoc"
}
####################
#Remove expired certs
####################
#$CertLocations = Get-ChildItem -Path Cert:\LocalMachine\AuthRoot |? {(Get-Date $_.NotAfter) -le ((Get-Date).AddDays(-7))}
#Foreach($CertLoc in $CertLocations) {
# Write-Host "$CertLoc"
# $CertLoc | Remove-Item
#}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment