Hello. I am a beginner of the powershell.
I need to check the expiry date by powershell, So I googled it!
Here’s the script that I copied from somewhere.
$daysremain=30
$certs = Get-ADComputer -Filter {Enabled -eq $True -and OperatingSystem -like “*Server*” -and Name -like “test*”} -SearchBase “OU=testgroup, OU=Server, OU=inhous, DC=test, DC=com” |% {Invoke-Command -ComputerName $_.name -ScriptBlock {Get-ChildItem cert:\LocalMachine\my -Recurse | Where-Object {$_ -is [System.Security.Cryptography.X509Certificates.X509Certificate2] -and $_.NotAfter -gt (Get-Date) -and $_.NotAfter -lt (Get-Date).AddDays($daysremain)| Select-Object PSComputerName, FriendlyName, NotAfter, Subject, Issuer}}}
Write-Output $certs
And then, I could not get the right result that I expected. Only I could see these objects
“Thumbprint, Subject, PSComputerName”.
I have no Idea what I have to do to figure it out.
Can you help me??
I’m sorry for not being fluent in English. If you don’t understand, please reply.