I'm developing code for monitoring memory that a specific program is using and then, if memory goes too high, it's gonna kill the process.
I'm wondering how I could remove extra blank spaces backward and forward the result, and then put the content into a variable.
Right now, the code is working, but it brings me some blank spaces. I know it's because of the Format-Table -Hide
function, but I don't know how to fix it.
Eg.: With Chrome process.
$Pmemory = Get-Process -Name chrome |
Group-Object -Property ProcessName |
Select @{n='Memory';e={'{0:N0}' -f (($_.Group|Measure-Object WorkingSet -Sum).Sum / 1MB)}} |
ft -hide |
Out-String
$Lmemory = 1000
After all, I'm gonna compare both values, but my main question is how to remove those blank spaces.