您好,我有一个Powershell脚本,可以使用该格式显示证书ssl的过期日期
notAfter = 2015年8月17日格林尼治标准时间
我只想提取日期(删除notAfter=
和GMT
),并确保我有一个Date格式的变量而不是一个字符串,那么我想从当前日期和得到的区别,我尝试删除和替换,但都没有改变。
更确切地说,这是为我提供notafter
值的命令
$timessl = ((& openssl x509 -in /etc/ssl/certs/certificate.pem -dates -noout) -match 'notAfter')
答案 0 :(得分:0)
尝试一下。
$timessl="notAfter=Aug 17 22:00:00 2015 GMT"
$t=$timessl.Replace("notAfter=","").Replace("GMT","")
write-output $t