Get-service syntax is wrong - want status of two services

Get-service syntax is wrong, i want to query two services to determine status
 
Get-service -computername cbsequ012 | ?{$_.Displayname -like "*DME*" AND  Displayname -like "*DRE*"}
 
At line:1 char:70
computername cbsequ012 | ?{$_.Displayname -like "*DME*" AND  Displa ...
  • You can do this multiple ways...
    Here, I am using RegEx matching


    Get-Service -ComputerName localhost | Select $_ | Where DisplayName -Match 'application|windows' | Sort DisplayName

    Status Name DisplayName
    ------ ---- -----------
    Stopped AppIDSvc Application Identity
    Running Appinfo Application Information
    Stopped ALG Application Layer Gateway Service
    Running AppMgmt Application Management
    Stopped c2wts Claims to Windows Token Service
    Stopped COMSysApp COM+ System Application
    Running SmsRouter Microsoft Windows SMS Router Service.
    Stopped QWAVE Quality Windows Audio Video Experience
    Stopped UsoSvc Update Orchestrator Service for Win...
    Running Audiosrv Windows Audio
    Running AudioEndpointBu... Windows Audio Endpoint Builder
    Stopped SDRSVC Windows Backup
    ...
  • In reply to postanote:

    Not what I wanted, I want to query two or three services. I know their display names. I am not sure of syntax and using the AND statement, the example given above has more info than required
    I am looking for the proper way of searching the follow. l ?{$_.displayname -like "*abc*" AND "*def*"}.
    What is the proper syntax?
  • In reply to cmje:

    If you are explicitly looking for exact service names / displaynames, then that means use the exact name vs wildcard (*) that you are using.

    So, just this...

    Get-Service -DisplayName 'application identity','Windows Update'


    Status Name DisplayName
    ------ ---- -----------
    Stopped AppIDSvc Application Identity
    Stopped wuauserv Windows Update