Home > Back-end >  How to format powershell output as per requirement
How to format powershell output as per requirement

Time:06-05

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?

CodePudding user response:

Try Name, Expression option while selecting

Get-WMIObject Win32_Service | Where-Object {$_.name -like "HyS9FinancialManagementJavaServer_*" }|Select-Object @{n="Name";e={(([String]($_.Name)).Split('_'))[1]}}
  • Related