【Windows Server】コマンドでサービス一覧を抜き出す方法まとめ

Windows Server

コマンドでサービス一覧を抜き出す方法をまとめました。

Get-Service (Microsoft.PowerShell.Management) - PowerShell
This cmdlet is only available on the Windows platform. The Get-Service cmdlet gets objects that represent the services o...

Powershellを使う

PowerShellでサービス一覧を確認するには以下のコマンドを使用します。

Get-Service

このままのコマンドだと、サービス名が途中で途切れてしまうので、以下のコマンドをPowerShellで実行します。また、表示名をアルファベット順で並べるために「 | Sort DisplayName」も追加します。

 Get-Service | Sort DisplayName | Format-Table -Autosize

Get-WmiObjectコマンドを使用することでもサービスの一覧を確認できます。引数に「-Class Win32_Service」を指定します。

Get-WmiObject -Class Win32_Service

Windows Management Instrumentation (WMI) クラスのインスタンスまたは使用可能なクラスに関する情報を取得します。

Get-WmiObject (Microsoft.PowerShell.Management) - PowerShell
Starting in PowerShell 3.0, this cmdlet has been superseded by Get-CimInstance. The Get-WmiObject cmdlet gets instances ...
Get-WmiObject -Class Win32_Service |sort DisplayName | Select Name, DisplayName, State, StartMode, DelayedAutoStart, StartName, PathName | Format-Table -Autosize

リモートでサービス一覧をコマンドで抜き出す

IPアドレス、192.168.10.1のコンピュータのサービス一覧を抜き出すには以下のコマンドを実行します。

Get-WmiObject -Class Win32_Service -ComputerName 192.168.10.1

以下のコマンドでadministratorユーザーでサインインしてサービス一覧を取得できます。コマンドを実行するとパスワードを求められます。

Get-WmiObject -Class Win32_Service -Credential domain-name\administrator -ComputerName hostname

タイトルとURLをコピーしました