2015年9月17日木曜日

◆svchostでホストされているサービスを表示する

Analyzing svchost Processes - Power Tips - PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources

 

サービスとプロセスをぶつけてsvchostでホストされているサービスを一覧表示する。(Ver3)

001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018

$service = @{
  Name 
= 'Service'
  Expression =
 
    {
     
if ($_.Name -eq 'svchost'
)
      {
      
$processID = $_.
ID
       (
$serviceList.$processID).Name -join ', '
      }
    }
}


$serviceList = gwmi -Class Win32_Service |
  group -Property ProcessID -AsString -AsHashTable

ps |
  Select -Property Name, ID, CPU, $service |
  Out-GridView

image

2015年9月2日水曜日

◆カスタムオブジェクトのプロパティ順を指定する

ハッシュテーブルを[Orderd]にキャストすると良いって話かな。

Creating New Objects - Oneliner - Power Tips - PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources