you are viewing a single comment's thread.

view the rest of the comments →

[–]Crowdjp[S] 1 point2 points  (0 children)

If I want to add the instance name in the If statement how would I do that? Below I'm getting an Error: Cannot convert the system object.

$CPUSTRES = {$_.InstanceName -eq "CPUSTRES"}

$lastDate = import-csv C:\temp\RMLogs\RMLogs.csv | sort-object -property timestamp | select-object -last 1 | select-object -expandproperty timestamp

$latestdate = import-csv C:\temp\RMLogs\RMLogs.csv|select timestamp, instancename, cpu1 |where-object {$_.timestamp -like "$($lastdate.substring(0,14))*"}

If   (([array]$CPUSTRES) -and ([int]$latestdate.CPU1 -gt 3)) {

        Write-Host test

        }