getting the last two words from Get-ADComputer

Hi All,

I am somewhat new to PowerShell. I need to get the last two words in Description following the last dash and before a word containing () if there is one. Here is what I have

$ComputerName = $env:COMPUTERNAME
$ADDescription = Get-ADComputer -Filter 'Name -eq $ComputerName' -Properties * | FT -hidetableheaders description -A
$UserName = $string -replace '^.*-|\S*[()]+\S*',''
echo $UserName
But when I run that I just get a blank. I'm stumped.

Well, Format-Table should not be used here. You can cherry pick the description from the output.

$Description = Get-ADComputer -Filter 'Name -eq $ComputerName' -Properties * | Select-Object -ExpandPorperty description

But, can you show the description you have, so that any one can help you with the proper regex pattern.

This needs RegEx matching, please share the sample description, one from each category.