Finding Keyboard and Mouse

by Feb 25, 2013

You can use WMI to quickly find all details about your mouse and keyboard:

PS> Get-WmiObject win32_PointingDevice | Where-Object { $_.Description -match 'hid'}
PS> Get-WmiObject win32_Keyboard | Where-Object { $_.Description -match 'hid'} 

You can also use this code to detect if a mouse is connected at all:

function Test-Mouse
{
 @(Get-WmiObject Win32_PointingDevice | Where-Object { $_.Description -match 'hid'}).Count -gt 0 
}

Twitter This Tip! ReTweet this Tip!