windows_service.msc/powershell:get-service检查/管理计算机上安装的服务

GUI :service.msc

通过任务管理器或者run窗口输入service.msc即可打开gui界面

powershell:与服务相关的cmdlet

gsvget-service命令的缩写别名

参考文档:

  • RELATED LINKs
    • New-Service
    • Restart-Service
    • Resume-Service
    • Set-Service
    • Start-Service
    • Stop-Service
    • Suspend-Service
    • Remove-Service

获取帮助示例
help gsv
help gsv -example
将获取使用示例

搜索服务(利用通配符)

实例


PS C:\Users\cxxu_11> gsv *edge*

Status   Name               DisplayName
Stopped  edgeupdate         Microsoft Edge Update Service (edge...
Stopped  edgeupdatem        Microsoft Edge Update Service (edge...
Stopped  MicrosoftEdgeEl... Microsoft Edge Elevation Service (M...

配合where 筛选结果

PS C:\Users\cxxu_11>   Get-Service | Where-Object {
    
    $_.Status -eq "Running"}

Status   Name               DisplayName
Running  Appinfo            Application Information
Running  AppMgmt            Application Management
Running  AudioEndpointBu... Windows Audio Endpoint Builder
Running  Audiosrv           Windows Audio
Running  BFE                Base Filtering Engine
Running  BrokerInfrastru... Background Tasks Infrastructure Ser...
Running  BthAvctpSvc        AVCTP service
.....
Running  CAJ Service Hos... CAJ Service Host
Running  camsvc             Capability Access Man

排序

可以通过管道符传递个sort指定排序键来排序显示

其他高级用法

从参考文档中获取相关信息:

    ------ Example 8: Get the dependent services of a service ------

    Get-Service "WinRM" -RequiredServices


    ---- Example 9: Get a service through the pipeline operator ----

    "WinRM" | Get-Service

gsv 命令的报错问题

某些情况下,gsv 直接执行的话会报错(字符串问题),导致gsv无法将完成的service 清单列出来

建议尽可能使用带筛选的gsv命令,这样不容以因为某些错误而阻断后续未显示的service

GUI vs powershell service series cmdlet

个人感觉,GUI查询到的列表比较滞后,有时干安装的服务需要重启(注销)重新登陆后才可以看到相应服务(比如我安装mysqld服务

但是powershell 中的相关命令很容易报错,使用起来体验不怎么好,但是可以执行一些查询和筛选.

Guess you like

Origin blog.csdn.net/xuchaoxin1375/article/details/121728653