【问题标题】:Extract Date Format using powershell使用PowerShell提取日期格式
【发布时间】:2019-05-13 13:22:10
【问题描述】:

您好,我有一个 powershell 脚本,它使用这种格式向我显示证书 ssl 的到期日期

notAfter=格林威治标准时间 2015 年 8 月 17 日 22:00:00

我只想提取日期(删除 notAfter= 和 GMT)并确保我有一个日期格式变量而不是字符串,然后我想从当前日期中提取该值并获得差异,我尝试删除和替换,但都没有改变。 更准确地说,这是给我notafter 值的命令

$timessl = ((& openssl x509 -in /etc/ssl/certs/certificate.pem -dates -noout) -match 'notAfter')

【问题讨论】:

    标签: powershell ssl


    【解决方案1】:

    试试这个。

    $timessl="notAfter=Aug 17 22:00:00 2015 GMT"
    $t=$timessl.Replace("notAfter=","").Replace("GMT","")
    write-output $t
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-23
      相关资源
      最近更新 更多