PoshCode Logo PowerShell Code Repository

load order by angry bird 2 weeks ago
embed code: <script type="text/javascript" src="http://PoshCode.org/embed/6723"></script>download | new post

Original post found [here](https://github.com/gregzakh/alt-ps/blob/master/tools/Show-LoadOrder.ps1)

  1. <#
  2.   .SYNOPSIS
  3.       Analogue of Sysinternals LoadOrd tool.
  4.   .NOTES
  5.       Author: greg zakharov
  6. #>
  7. $root = 'HKLM:\SYSTEM\CurrentControlSet\Control'
  8. $type, $list = (Get-ItemProperty "$($root)\ServiceGroupOrder").List, (
  9.   Get-ItemProperty "$($root -replace 'control\Z', 'services')\*" |
  10.   Where-Object { [Int32]$_.Start -lt 3 }
  11. )
  12.  
  13. $s1, $s2, $s3 = @(), @(), @()
  14. foreach ($t in $type) {
  15.   if ((
  16.     $obj = $list | Where-Object { $_.Group -eq $t }
  17.   ) -eq $null) { continue }
  18.  
  19.   $obj = if ($obj -is [Array]) {
  20.     $rk = Get-Item "$($root)\GroupOrderList"
  21.    
  22.     $val, $arr = $rk.GetValue($t), @()
  23.     if ($val) {
  24.       for ($i = 0; $i -lt $val.Length; $i += 3) {
  25.         $arr += [BitConverter]::ToUInt16($val[$i..($i + 3)], 0)
  26.         $i++
  27.       }
  28.       $arr = $arr[1..($arr.Length - 1)]
  29.      
  30.       foreach ($a in $arr) {
  31.         $obj | Where-Object { [UInt16]$_.Tag -eq $a }
  32.       }
  33.     }
  34.    
  35.     $rk.Dispose()
  36.   }
  37.   else { $obj }
  38.  
  39.   foreach ($o in $obj) {
  40.     switch ($o.Start) {
  41.       0 { $s1 += $o }
  42.       1 { $s2 += $o }
  43.       2 { $s3 += $o }
  44.     }
  45.   }
  46. }
  47.  
  48. $s1 + $s2 + $s3 | Select-Object @{N='Start value';E={
  49.   switch ($_.Start) { 0 {'Boot'}; 1 {'System'}; 2 {'Automatic'} }
  50. }}, @{N='Group name';E={$_.Group}}, Tag, @{
  51.   N='Service/Device';E={$_.PSChildName}
  52. }, @{N='Display name';E={$_.DisplayName}}, @{
  53.   N='Image path';E={$_.ImagePath}
  54. } | Out-GridView -Title LoadOrd

Submit a correction or amendment below (
click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:


Remember me