Load Recent Content
Ouch. That renders the printout almost useless. I've filed this internally as a major bug.Not being aware of Gustav's bug report, I submitted one about two months ago:
$ListOfServers = Get-ADComputer -Filter {Enabled -eq $True -and OperatingSystem -like "*Server*"} -SearchBase "DC=Domain,DC=com"
# If you want in in a text files containing server list or names
#$ListOfServers = Get-Content "c:\temp\serv.txt"
Foreach ($Server in $ListOfServers) {
Invoke-Command -ComputerName $Server -ScriptBlock {
# Get Certificate list and assign to a variable
$Certs = Get-ChildItem "Cert:\LocalMachine\My" -Recurse
#To get a list of all cert storage locations.
#(Get-ChildItem -Path "Cert:" -Recurse | Where-Object {($_).GetType().Name -eq 'X509Store'}).Name
# Loop through each object in $Certs
Foreach ($Cert in $Certs) {
# If The objects property "NotAfter" is older than the current time, delete
If ($Cert.NotAfter -lt (Get-Date)) {
$Cert | Remove-Item -WhatIf # Remove the -WhatIf to make it run for real.
}
}
}
}
244
Solutions
572
Contributors
Experts Exchange is a collaborative community of technology professionals!
We facilitate collaboration, learning, and problem solving through conversations and content in more than 230 technology topics.
The Original Tech Community