Forum Discussion
3 years ago
$paths = @()
$paths += ,@("\\xxxxxxxxxx1\share\folder\")#Location0 Site Code: AB
$paths += ,@("\\xxxxxxxxxxx2\share\folder\")#Location1 Site Code: CD
$statuses = @(0) * $paths.Count
$location=[int]0
$i=0
foreach ($path in $paths){
if(!(Test-path $path)){
$statuses[$location]= 1
$location++
continue
}
$file = gci $path | sort LastWriteTime | select -last 1
if($file.LastWriteTime -lt (Get-Date).AddDays(-1)){
$statuses[$location]= 1
}
$location++
}
foreach($status in $statuses){
Write-Host Location$i=$status
$i++
}
exit 0
I missed the bottom of my code in my code insert in the first post.
Results of above example;
Location0=0
Location1=0
Location2=0
Location3=1 (fail path and or lastwritetime)
Related Content
- 8 months ago
- 11 months ago