Last active
December 29, 2019 22:45
-
-
Save brokenwindupdoll/07575ac26b002c2111bce950b780ccc1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Param | |
( | |
[string]$ComputerName = $env:ComputerName, | |
[string]$Class, | |
[string]$Manufacturer, | |
[string]$Name | |
) | |
$pnp = Get-WmiObject -Class "Win32_PNPEntity" -ComputerName $ComputerName | |
if ($Class) | |
{ | |
$pnp = $pnp | Where-Object { $_.Name -match $Class } | |
} | |
if ($Manufacturer) | |
{ | |
$pnp = $pnp | Where-Object { $_.Name -match $Manufacturer } | |
} | |
if ($Name) | |
{ | |
$pnp = $pnp | Where-Object { $_.Name -match $Name } | |
} | |
$pnp | ForEach-Object { | |
try | |
{ | |
$PCIeCurrentSpeed = ($_.GetDeviceProperties('DEVPKEY_PciDevice_CurrentLinkSpeed').deviceProperties[0].Data).ToString() | |
$PCIeCurrentWidth = ($_.GetDeviceProperties('DEVPKEY_PciDevice_CurrentLinkWidth').deviceProperties[0].Data).ToString() | |
$PCIeMaxSpeed = ($_.GetDeviceProperties('DEVPKEY_PciDevice_MaxLinkSpeed').deviceProperties[0].Data).ToString() | |
$PCIeMaxWidth = ($_.GetDeviceProperties('DEVPKEY_PciDevice_MaxLinkWidth').deviceProperties[0].Data).ToString() | |
New-Object PSObject -Property @{ | |
"Name" = $_.Name; | |
"Class" = $_.PNPClass; | |
"Manufacturer" = $_.Manufacturer; | |
"PCIe Link" = "$PCIeCurrentSpeed x$PCIeCurrentWidth"; | |
"PCIe Max" = "$PCIeMaxSpeed x$PCIeMaxWidth"; | |
} | |
} | |
catch {} | |
} | Sort-Object Class,Name | Select-Object Name,Manufacturer,Class,'PCIe Link','PCIe Max' | Format-Table |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment