Any help will be appreciated.
I have hundred of servers with Certs in the LocalMachine\My Store.
I can see the Cert opening a Session and Running Get-ChildItem cert:\Localmachine\my.
Is their a way that I removed only the Cert that are expired using a powershell script?
I have a list of servers in a text file.
I have tried this with no success:
$today = Get-Date
$session = New-PsSession –ComputerName TestServer
Invoke-Command -ComputerName $session { Get-ChildItem -Path Cert:\LocalMachine\My } | foreach { If ( $.NotAfter -lt $today) { $.Remove($Cert) }
}
Thanks!