How to get all Windows service names starting with a common word?

前端 未结 3 459
[愿得一人]
[愿得一人] 2021-01-30 02:29

There are some windows services hosted whose display name starts with a common name (here NATION). For example:

  • NATION-CITY
  • NATION-STATE
  • NATION-
3条回答
  •  不知归路
    2021-01-30 02:40

    Using PowerShell, you can use the following

    Get-Service | Where-Object {$_.displayName.StartsWith("NATION-")} | Select name
    

    This will show a list off all services which displayname starts with "NATION-".

    You can also directly stop or start the services;

    Get-Service | Where-Object {$_.displayName.StartsWith("NATION-")} | Stop-Service
    Get-Service | Where-Object {$_.displayName.StartsWith("NATION-")} | Start-Service
    

    or simply

    Get-Service | Where-Object {$_.displayName.StartsWith("NATION-")} | Restart-Service
    

提交回复
热议问题