USBRecords/USBRecords.psm1
<#
.SYNOPSIS Gets the USB connections made by this Computer. .DESCRIPTION The Get-USBConnections cmdlet gets the Device Description, manufacturer and Service Used by that USB connections. .EXAMPLE PS> Get-USBConnections The USB Connections Records : DeviceDesc :: Redmi Note 5 Pro Mfg :: Xiaomi Service :: WUDFWpdMtp #> Function Get-USBConnections { Write-Output " " Write-Output "The USB Connections Records : " $x = Get-ChildItem HKLM:\SYSTEM\CurrentControlSet\Enum\USB\*\*\ $val = "DeviceDesc","Mfg","Service","FriendlyName" $Count = 0 $countnext = 0 $MainCount = 0 while ($MainCount -ine $x.Count){ $y = $x[$MainCount].Property $MainVal = $null $countnext = 0 while ($countnext -ine $val.count){ if ($y.Contains($val[$countnext]) -eq 'True' ) { [System.Array]$MainVal += $val[$Countnext] } $countnext++ } Write-Output " " $CountThird = 0 while ($CountThird -ine $MainVal.Count) { $t = $x[$MainCount] | Get-ItemPropertyValue -name $MainVal[$CountThird] Write-Host $MainVal[$CountThird] "::" $t $CountThird++ } $MainCount++ } } <# .SYNOPSIS Gets the USB Storage connections made by this Computer. .DESCRIPTION The Get-USBStorages cmdlet gets the Device Description, manufacturer and Service Used by that USB connections. .EXAMPLE PS> Get-USBStorages The USB Storage Records : DeviceDesc :: @disk.inf,%disk_devdesc%;Disk drive Mfg :: @disk.inf,%genmanufacturer%;(Standard disk drives) Service :: disk FriendlyName :: SanDisk Cruzer Blade USB Device #> Function Get-USBStorages { Write-Output " " Write-Output "The USB Storage Records : " $x = Get-ChildItem 'HKLM:\SYSTEM\CurrentControlSet\Enum\USBSTOR\*\*\' $val = "DeviceDesc","Mfg","Service","FriendlyName" $Count = 0 $countnext = 0 $MainCount = 0 while ($MainCount -ine $x.Count){ $y = $x[$MainCount].Property $MainVal = $null $countnext = 0 while ($countnext -ine $val.count){ if ($y.Contains($val[$countnext]) -eq 'True' ) { [System.Array]$MainVal += $val[$Countnext] } $countnext++ } Write-Output " " $CountThird = 0 while ($CountThird -ine $MainVal.Count) { #write-host $MainVal[$CountThird] $t = $x[$MainCount] | Get-ItemPropertyValue -name $MainVal[$CountThird] Write-Host $MainVal[$CountThird] "::" $t $CountThird++ } $MainCount++ } } |