【发布时间】:2018-09-20 14:23:38
【问题描述】:
如果找到字符串,我正在尝试打印文件的路径。问题是如果 1 个文件不包含文件夹中的字符串,那么我不会得到任何输出。基本上,我正在查看证书纪元时间是否在到期后的 30 天内。以下是我的代码:
$c = Get-Date (Get-Date).ToUniversalTime() -UFormat %s
$epochtimes=[math]::Round($c)
$d = get-childitem C:\scripts\PALO\* -recurse | Select-String -pattern
"expiry-epoch"
$e=$d -split "epoch"
$certtime=[double] $e[1]
$certexp = $certtime - 2592000
ForEach ($i in $certexp){
If ($certexp -le $epochtime) {
Write-Host $i
}
}
【问题讨论】:
标签: powershell if-statement foreach