Public/Hardware/Get-PeripheralDevice.ps1
<#
Copyright © 2024 Integris. For internal company use only. All rights reserved. #> FUNCTION Get-PeripheralDevice { <# .SYNOPSIS Retrieves and displays information about peripheral devices connected to the system. .DESCRIPTION This function collects detailed information about various peripheral devices, including USB video devices, audio devices, cameras, and USB printers. It gathers details such as device type, name, service, manufacturer, and capabilities. .EXAMPLE Get-PeripheralDevice This command retrieves information about all connected peripheral devices on the system. .NOTES This function uses CIM instances to gather peripheral device information and may require appropriate permissions to execute. #> [CmdletBinding()] PARAM ( ) $Results = @() $Items = @() $Items += Get-CIMInstance Win32_PnPEntity -ErrorAction SilentlyContinue | Where-Object { $_.Service -eq "WSDScan" } $Items += Get-CIMInstance Win32_PnPEntity -ErrorAction SilentlyContinue | Where-Object { $_.Service -eq "usbaudio" } $Items += Get-CIMInstance Win32_PnPEntity -ErrorAction SilentlyContinue | Where-Object { $_.Service -eq "usbvideo" } $Items += Get-CIMInstance Win32_PnPEntity -ErrorAction SilentlyContinue | Where-Object { $_.PNPClass -eq "Camera" } FOREACH ($Item in $Items) { IF ($Item.Service -eq "usbvideo") { $Description = "USB Video Device" } ELSE { $Description = $Item.Description } $Results += New-Object PSObject -WarningAction SilentlyContinue -Property @{ PSTypeName = 'IntegrisPowerShell.PeripheralDevice' DeviceType = $Description DeviceName = $Item.Caption Service = $Item.Service Manufacturer = $Item.Manufacturer PNPClass = $Item.PNPClass DriverName = "" } } $Items = Get-CIMInstance Win32_Printer -ErrorAction SilentlyContinue | Where-Object { $_.PortName -like "*USB*" } FOREACH ($Item in $Items) { $Results += New-Object PSObject -WarningAction SilentlyContinue -Property @{ PSTypeName = 'IntegrisPowerShell.PeripheralDevice' DeviceType = "USB Printer Device" DeviceName = $Item.Caption Service = $Item.PortName Manufacturer = "" PNPClass = $Item.CreationClassName DriverName = $Item.DriverName } } RETURN $Results } New-Alias -Name Get-PeripheralInfo -Value Get-PeripheralDevice |