So I run this command
$driverRAIDv = $data|where-object{$_.Name -eq "$serverName" -and ($_.Description1 -match "hpsa")} | select -ExpandProperty version
And it returns this value:
HP HPSA Driver (v 5.0.0-28OEM)
I want to take this value/variable and parse it so that I only have 5.0.0-28OEM
Best How To :
Try this, matches anything between (
and )
brackets:
EDIT: ..and removes the v followed by a space:
$driverRAIDv = $data|where-object{$_.Name -eq "$serverName" -and ($_.Description1 -match "hpsa")} | select -ExpandProperty version
$regex = "(?<=\().*(?=\))"
[regex]::matches($driverRAIDv,$regex).Value -replace "v "
which returns:
5.0.0-28OEM
or you could use following regex which will match anything between (v
and )
$regex="(?<=\(v\s).*(?=\))"