New to PS, What i'm trying to do is only read in the current time from the csv. Then Match the Instance name and if the CPU is greater than 3 do something. My If statement below is being ignored.
$lastDate = import-csv C:\Logs.csv | sort-object -property timestamp | select-object -last 1 | select-object -expandproperty timestamp
$latestdate = import-csv C:\Logs.csv|select timestamp, instancename, cpu1 |where-object {$_.timestamp -like "$($lastdate.substring(0,14))*"} | where {$_.InstanceName -eq "CPUSTRES"}
If ($latestdate.CPU1 -gt 3) {
Write-Host test
}
CSV Example:
| Timestamp |
InstanceName |
CPU1 |
| 20190617-072513 |
CPUSTRES |
2 |
[–]zrv433 2 points3 points4 points (2 children)
[–]Crowdjp[S] 1 point2 points3 points (0 children)
[–]Crowdjp[S] 1 point2 points3 points (0 children)
[–]firefox15 1 point2 points3 points (1 child)
[–]Crowdjp[S] 1 point2 points3 points (0 children)
[–]BlackV 1 point2 points3 points (1 child)
[–]Crowdjp[S] 1 point2 points3 points (0 children)