Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Regex help

$
0
0

Hi, i hav a command that gets the ram memory of the servers in GB

$RAM = Get-WMIObject -class Win32_PhysicalMemory -computername $server | Measure-Object -Property capacity -Sum | select @{N="Ram"; E={[math]::round(($_.Sum / 1GB),2)}} 

The problem is that one of the servers has 256 GB but powershell commands gets 255.99

Having this figure breaks another part of the script.

Ho i want the regex to only show 255 instead of 255.99

I can do a replace the dot with:

$ram = $ram.Ram -replace '\.', ' '

But how can i get rid of everything after the dot so it only shows 255?

Thanks


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>