- <#
- .SYNOPSIS
- Uses Win32_PointingDevice WMI class to return Mouse details.
- .DESCRIPTION
- This script first defines some functions to decode various
- WMI attributed from binary to text. Then the script calls
- Get-WmiObject to retrieve Mouse details, then formats that
- information (using the functions defined at the top of the script.
- While on most systems, there is only one mouse, WMI can return
- multiple devices. Hence the foreach loop. Thanks to Jeffrey
- Snover for the tip-off! Also note that not all properties
- are returned – although mileage may vary.
- This is also sample 7 on http://msdn.microsoft.com/en-us/library/aa394587(VS.85).aspx
- recoded with PowerShell.
- .NOTES
- File Name : Get-Mouseinfo.ps1
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : PowerShell V2 CTP3
- .LINK
- Script posted to:
- http://www.pshscripts.blogspot.com
- Original MSDN Page
- http://msdn.microsoft.com/en-us/library/aa394587(VS.85).aspx
- .EXAMPLE
- PS C:\foo> Get-Mouseinfo.ps1
- Mouse Information on System: COOKHAM8 (device 1)
- Description : PS/2 Compatible Mouse
- Device ID : ACPI\PNP0F13\4&33DCE2F0&0
- Device Interface : PS/2
- Double Speed Threshold :
- Handedness :
- Hardware Type : PS/2 Compatible Mouse
- INF File Name : msmouse.inf
- Inf Section : PS2_Inst
- Manufacturer : Microsoft
- Name : PS/2 Compatible Mouse
- Number of buttons : 0
- PNP Device ID : ACPI\PNP0F13\4&33DCE2F0&0
- Pointing Type : Unknown
- Quad Speed Threshold :
- Resolution :
- Sample Rate :
- Synch :
- #>
- ###
- # Start of Script
- ###
- # Functions to decode details
- function Deviceinterface {
- param ($value)
- switch ($value) {
- 0 {"Other"}
- 1 {"Unknown"}
- 3 {"Serial"}
- 4 {"PS/2"}
- 5 {"Infrared"}
- 6 {"HP-HIL"}
- 7 {"Bus Mouse"}
- 8 {"ADP (Apple Desktop Bus)"}
- 160 {"Bus Mouse DB-9"}
- 161 {"Bus Mouse Micro-DIN"}
- 162 {"USB"}
- }
- }
- function Handedness {
- param ($value)
- switch ($value) {
- 0 {"Unknown"}
- 1 {"Not Applicable"}
- 2 {"Right-Handed Operation"}
- 3 {"Left-Handed Operation"}
- }
- }
- function Pointingtype {
- param ($value)
- switch ($value) {
- 1 {"Other"}
- 2 {"Unknown"}
- 3 {"Mouse"}
- 4 {"Track Ball"}
- 5 {"Track Point"}
- 6 {"Glide Point"}
- 7 {"Touch Pad"}
- 8 {"Touch Screen"}
- 9 {"Mouse - Optical Sensor"}
- }
- }
- # Now do script stuff
- # Get Mouse information
- $mice = Get-WmiObject -Class Win32_PointingDevice
- $i=1
- foreach ($mouse in $mice) {
- # Display details
- "Mouse Information on System: {0} (device {1})" -f $mouse.systemname, $i
- "Description : {0}" -f $mouse.Description
- "Device ID : {0}" -f $mouse.DeviceID
- "Device Interface : {0}" -f (Deviceinterface($mouse.DeviceInterface))
- "Double Speed Threshold : {0}" -f $mouse.DoubleSpeedThreshold
- "Handedness : {0}" -f (Handedness($mouse.handedness))
- "Hardware Type : {0}" -f $mouse.Hardwaretype
- "INF File Name : {0}" -f $mouse.InfFileName
- "Inf Section : {0}" -f $mouse.InfSection
- "Manufacturer : {0}" -f $mouse.Manufacturer
- "Name : {0}" -f $mouse.Name
- "Number of buttons : {0}" -f $mouse.NumberOfButtons
- "PNP Device ID : {0}" -f $mouse.PNPDeviceID
- "Pointing Type : {0}" -f (Pointingtype ($mouse.PointingType))
- "Quad Speed Threshold : {0}" -f $mouse.QuadSpeedThreshold
- "Resolution : {0}" -f $mouse.Resolution
- "Sample Rate : {0}" -f $mouse.SampleRate
- "Synch : {0}" -f $mouse.Synch
- $i++
- }
- # End of Script
This blog contains PowerShell scripts, more PowerShell scripts and still more PowerShell scripts. Occasionally you may see some organisational posts.
Saturday 3 January 2009
Get-MouseInfo.ps1
Labels:
PowerShell scripts,
PowerShell V2,
Win32_PointingDevice,
wmi
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment