Author Posts

June 23, 2015 at 2:06 am

Hi,

I'm checking the date of when some certificates expiry. The main part is:

gci -path cert: -Recurse).GetExpirationDateString()

I can split it fine by .split(' '), but i want all the dates separate. Any ideas ?

Thanks

June 23, 2015 at 3:37 am

I can't get the method working but using a string as an example, you could do something like this:

$dateString = '23/06/2015 12:36:00'
$date = ($dateString -split ' ')[0]
$time = ($dateString -split ' ')[1]

June 23, 2015 at 6:29 am

Try something like this:

gci -path cert: -Recurse | Select Name, @{Label="ExpirationDate";Expression={$_.GetExpirationDateString()}}

If that doesn't work, you may need to use foreach logic, like this

$results = gci -path cert: -Recurse | foreach{ New-Object -TypeName PSObject -Property @{Name=$_.Name;ExpirationDate=$_.GetExpirationDateString()} }
$results