Greetings, thanks for any help debugging this script.
Here is the link where I found the script.
PowerShell: Create a Certificate Expiration Warning
https://www.incworx.com/blog/powershell-create-a-certificate-expiration-warning-system
Here is the whole script listed out.
Variable to store the location of the CSV report
$reportPath = "C:\Temp\CertificatesReport.CSV"
Create a tab delimited header row to label each property
("Path`tSubject`tIssuer`tThumbprint`tFriendly Name`tValid From`tValid To`tDays Until Expiration") | Out-File -FilePath $reportPath
Store today's date as a variable
$now = Get-Date
Iterate through each certificate and export the properties to the CSV report
Get-ChildItem Cert:\LocalMachine -Recurse | ForEach-Object {
$daysUntilExpiration = (New-TimeSpan -Start $now -End $.NotAfter).Days;
($.PSPath + "`t" + $_.Subject + "t" + $_.Issuer + "t" + $_.Thumbprint + "t" + $_.FriendlyName + "t" + $_.NotBefore + "t" + $_.NotAfter + "t" + `
$daysUntilExpiration) | Out-File -FilePath $reportPath -Append -NoClobber
}