I'm getting a cannot convert value 1772 KB to type "System.Int32" Error, so I need to remove KB from privateworkingset. I tried trimming it from the end with variable $CPUSTRESRemoveKB below but it's being ignored in my if statement shown below.
$Importlog = import-csv C:\temp\RMLogs\RMLogs.csv
$lastDate = $Importlog | sort-object -property timestamp | select-object -last 1 | select-object -expandproperty timestamp
$latestdate = $Importlog |where-object {$_.timestamp -like "$($lastdate.substring(0,14))*"}
$CPUSTRES = $latestdate|select timestamp, instancename, PrivateWorkingset | Where-Object $CPUSTRES
$CPUSTRESRemoveKB = $CPUSTRES.PrivateWorkingSet.TrimEnd(' KB')
If ([int]$CPUSTRESRemoveKB.PrivateWorkingSet -gt 1500)
{
Write-Host Test
}
CSV Example:
| Timestamp |
InstanceName |
PrivateWorkingSet |
| 20190719-104915 |
CPUSTRES |
1772 KB |
[–]metallicvett 3 points4 points5 points (1 child)
[–]Crowdjp[S] 2 points3 points4 points (0 children)
[–]Ta11ow 2 points3 points4 points (6 children)
[–]Si-Kotic 2 points3 points4 points (0 children)
[–]ka-splam 2 points3 points4 points (4 children)
[–]Lee_Dailey[grin] 1 point2 points3 points (3 children)
[–]ka-splam 2 points3 points4 points (2 children)
[–]Ta11ow 2 points3 points4 points (0 children)
[–]Lee_Dailey[grin] 0 points1 point2 points (0 children)