リスト内のサービスを手動で停止/開始するためのスクリプトをたくさん見てきましたが、自動サービスだけでプログラムでそのリストを生成するにはどうすればよいですか。再起動のスクリプトを作成したいのですが、想定されていたすべてのサービスですべてが実際に正しく起動したことを確認する方法を探しています。
15383 次
1 に答える
11
Get-Service
System.ServiceProcess.ServiceController
この情報を公開しないオブジェクトを返します。したがって、次のようなタスクには WMI を使用する必要がありますGet-WmiObject Win32_Service
。必要なものを示し、StartMode
Windows コントロール パネルで出力をフォーマットする例:
Get-WmiObject Win32_Service |
Format-Table -AutoSize @(
'Name'
'DisplayName'
@{ Expression = 'State'; Width = 9 }
@{ Expression = 'StartMode'; Width = 9 }
'StartName'
)
自動化されているが実行されていないサービスに関心があります。
# get Auto that not Running:
Get-WmiObject Win32_Service |
Where-Object { $_.StartMode -eq 'Auto' -and $_.State -ne 'Running' } |
# process them; in this example we just show them:
Format-Table -AutoSize @(
'Name'
'DisplayName'
@{ Expression = 'State'; Width = 9 }
@{ Expression = 'StartMode'; Width = 9 }
'StartName'
)
于 2010-05-07T03:30:48.970 に答える