PoshCode Archive  Artifact Content

Artifact a7ef323f64207303afe15da5f528a9de1a4a6c6121e231194b16bc9e3af7001d:

  • File lspci.ps1 — part of check-in [dde8bef497] at 2018-06-10 13:55:06 on branch trunk — Analog of UNIX lspci basic functionality. (user: greg zakharov size: 1037)

# encoding: ascii
# api: powershell
# title: lspci
# description: Analog of UNIX lspci basic functionality.
# version: 0.1
# type: function
# author: greg zakharov
# license: CC0
# function: Get-PCIDevices
# x-poshcode-id: 5418
# x-archived: 2017-04-10T11:25:36
# x-published: 2017-09-11T15:22:00
#
#
#requires -version 2.0
Set-Alias lspci Get-PCIDevices

function Get-PCIDevices {
  <#
    .NOTES
        Author: greg zakharov
  #>
  
  gci HKLM:\SYSTEM\CurrentControlSet\Enum\PCI | % {
    gp (gci $_.PSPath).PSPath | select @{
      N='DeviceID'; E={
        $i = ([Regex]"\d+").Matches($_.LocationInformation)
        '{0:x2}:{1:x2}.{2}' -f [Int32]$i[0].Value, [Int32]$i[1].Value, $i[2].Value
      }
    }, Class, @{
      N='Device'; E={$_.DeviceDesc}
    }, @{
      N='DriverDate'; E={
        ($script:r = gp (Join-Path HKLM:\SYSTEM\CurrentControlSet\Control\Class $_.Driver)).DriverDate
      }
    }, @{
      N='DriverVersion'; E={$r.DriverVersion}
    }
  } | sort DeviceID | ft -a
}