I am running below PowerShell command to lookup a specific windows service.
Get-WMIObject Win32_Service | Where-Object {$_.name -like "HyS9FinancialManagementJavaServer_*" }|select name
which gives me expected output of
HyS9FinancialManagementJavaServer_epmsystem1.
My requirement is get only the string after _. Is there a way to achieve this in PowerShell?
-replace '.*_'to remove everything up to and including the _.(Get-WMIObject Win32_Service | Where-Object { $.name -Like 'HyS9FinancialManagementJavaServer*' } | Select-Object -ExpandProperty Name ) -replace '.*_'$.nameto$_.name---(Get-WMIObject Win32_Service | Where-Object { $_.Name -Like 'HyS9FinancialManagementJavaServer*' } | Select-Object -ExpandProperty Name ) -replace '.*_'^.*_.*will not match everything from the start of the line?