Give this a try. Basically, we're creating a "calculated property" that contains an expression to parse out the portion of the value that you want.
$driverRAIDv = $data|where-object{$_.Name -eq "$serverName" -and ($_.Description1 -match "hpsa")} | select -Property @{ Label = 'Version'; Expression = { [void]($_ -match ('v\s(.*?)\)')); $matches[1]; }; };
I tested this out using the following code:
@{ Version = 'HP HPSA Driver (v 5.0.0-28OEM)'} | select -Property @{ Label = 'Version'; Expression = { [void]($_ -match ('v\s(.*?)\)')); $matches[1]; }; };
If you check out the help for the Select-Object command, you will see that you can create calculated properties, which basically modify the value of a property, through a PowerShell expression. To do this, create a Hashtable that contains two items: Label and Expression. The Label can simply be set to the same property value that you're modifying. The Expression is a PowerShell ScriptBlock that performs some type of operation, and returns a result. In the example I gave above, we are running a regular expression against the Version property, and returning it as the result.
