0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Windowsのサービス一覧を出すコマンド

Last updated at Posted at 2024-09-23

トリガー開始とか遅延開始とかの情報がどこにあるのか調べてみたらレジストリにあるらしいです。

個人的にはアルファベットの方が後で加工しやすいので、コピペで使える日本語無しバージョンを用意しました。

function Get-CompleteService {
    $triggers = Get-ChildItem "HKLM:\SYSTEM\CurrentControlSet\Services" |
        Where-Object { $_.GetSubkeyNames().Contains("TriggerInfo") } |
        ForEach-Object { $_.Name.Split("\")[-1] }

    $startOption = @{ 01 = "(Trigger)"; 10 = "(DelayedStart)"; 11 = " (DelayedStart,Trigger)" }

    return Get-CimInstance -ClassName Win32_Service | Select-Object @(
        @{ n = "DisplayName"; e = { $_.DisplayName } }
        @{ n = "Name";        e = { $_.Name } }
        @{ n = "StartType";   e = { $_.StartMode + $startOption[10 * ($_.StartMode -eq "Auto" -and $_.DelayedAutoStart) + $triggers.Contains($_.Name)] } }
        @{ n = "Status";      e = { $_.State } }
    )
}
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?