Help to search and print line with greater than like 50%

Hi All,

I am new to powershell, please suggest.

i was using Select-String -Path | -pattern, but it only search the given value.

I am trying to search and print line if that line value is 50% and above.
ex: Print WESTDEV have 82%,81% that line has to be printed and send email.

. Print EASTDEV
/dev/sdb 984G 289G 695G 30% /var/lib/influxdb
/dev/sdb 984G 286G 699G 29% /var/lib/influxdb
. Print WESTDEV
/dev/sde 984G 798G 187G 82% /var/lib/influxdb
/dev/sdc 984G 793G 192G 81% /var/lib/influxdb
. Print EASTPST
/dev/sdd 984G 439G 545G 45% /var/lib/influxdb

Hi, welcome to the forum :wave:

Firstly, when posting code, data, and errors in the forum, please can you use the preformatted text </> button. It really helps us with readability, and copying and pasting your code (we don’t have to faff about replacing curly quote marks to get things working).
How to format code on PowerShell.org

To find the percentage value above 50, you will need to use a regular expression:

Select-String -Path .\data.txt -Pattern '[5-9][0-9]%|100%' | 
    Select-Object -ExpandProperty Line

To send an e-mail use Send-MailMessage

2 Likes

Thank you matt ! it worked for me.

1 Like