Quantcast
Channel: Windows PowerShell Forum
Viewing all articles
Browse latest Browse all 2314

Hilfe bei Scriptänderung

$
0
0

Hallo,

habe leider keine Ahnung von Powershell.

Das folgende Script ist für eine Dateiüberwachung im Einsatz. Es soll nur prüfen, ob eine Datei vorhanden ist. Es prüft aber auch, ob diese Datei in den letzten 24 Std. geändert wurde. Das würde ich gerne heraushaben. Kann mir das jemand machen?

Vielen Dank

Dieter

if (Test-Path "$env:FileToBeFound")
{
if ( ((get-date) - (ls $env:FileToBeFound).LastWriteTime).days -lt 1)
{
    Write-Host "<-Start Result->"
    Write-Host "-=OK"
    Write-Host "<-End Result->"
    Exit 0
}
else
{
    Write-Host "<-Start Result->"
    Write-Host "-=File found but not modified in the last 24 hours"
    Write-Host "<-End Result->"
    Exit 1
}
}
else
{
    Write-Host "<-Start Result->"
    Write-Host "-=File not found"
    Write-Host "<-End Result->"
    Exit 1
}


Viewing all articles
Browse latest Browse all 2314


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>