Skip to content

Instantly share code, notes, and snippets.

@brokenwindupdoll
Last active December 29, 2019 22:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brokenwindupdoll/07575ac26b002c2111bce950b780ccc1 to your computer and use it in GitHub Desktop.
Save brokenwindupdoll/07575ac26b002c2111bce950b780ccc1 to your computer and use it in GitHub Desktop.
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