Skip to content

Instantly share code, notes, and snippets.

@Beercow
Created August 1, 2022 18:24
Show Gist options
  • Save Beercow/88a67038f8f0729a0654fb646e3aed55 to your computer and use it in GitHub Desktop.
Save Beercow/88a67038f8f0729a0654fb646e3aed55 to your computer and use it in GitHub Desktop.
Enumerate USBSTOR:
Get-ItemProperty -path HKLM:\SYSTEM\CurrentControlSet\Enum\USBSTOR\*\* |Select `
@{ n = 'Vendor'; e= { ((($_.PSParentPath -split '[\\]')[-1] -split '[&]')[-3] -split 'Ven_')[-1] } }, `
@{ n = 'Product'; e= { ((($_.PSParentPath -split '[\\]')[-1] -split '[&]')[-2] -split 'Prod_')[-1] } }, `
@{ n = 'Version'; e= { ((($_.PSParentPath -split '[\\]')[-1] -split '[&]')[-1] -split 'Rev_')[-1] } }, `
@{ n = 'Serial_Number'; e= { ($_.PSPath -split '[\\]')[-1] } }, `
@{ n = 'Unique_Serial'; e= { if ((($_.PSPath -split '[\\]')[-1]) -like '?&*'){"No"} else {"Yes"} } } | Format-Table
Enumerate MountedDevices:
$key="HKLM:\SYSTEM\MountedDevices"
$dlvn=Get-Item $key | select -Expand property
$data=Get-Item $key | select -Expand property | % {
$value = (Get-ItemProperty -Path $key -Name $_).$_
[System.Text.Encoding]::Unicode.GetString($value)
}
$dlvn | Foreach {$i=0}{new-object pscustomobject -prop @{Driveletter=$_;Data=$data[$i]}; $i++} | Format-Table
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment