I would like to ask for some help regarding an incrementing value applied in the script below For each certificate it found, a counter increments by 1, I tried usig $i=0; $i++ but I'm not getting anywhere.
$Expiry = Get-ChildItem -Path cert: -Recurse
$Rep= @()
Foreach ($cert in $Expiry)
{
if ($cert.notafter -le (get-date).Adddays(120) -AND $cert.notafter -gt (get-date))
{
$obj = New-Object PSObject
$Daysleft = $Cert.NotAfter - (get-date)
$obj | Add-Member -type NoteProperty -Name "Path" $cert.PSParentPath
$obj | Add-Member -type NoteProperty -Name "Issuer" $cert.Issuer
$obj | Add-Member -type NoteProperty -Name "NotAfter" $cert.NotAfter
$obj | Add-Member -type NoteProperty -Name "DaysLeft" $Daysleft.Days
$Rep +=$obj
}
}
My goal here is if it satisfies the condition, it will display the certificate and a counter will be plus 1. until it completes the loop then it displays the total certificates found
Hoping for your help
Thank you