Showing posts with label Win32_PointingDevice. Show all posts
Showing posts with label Win32_PointingDevice. Show all posts

Sunday, 4 January 2009

Get-NonWorkingDevices.ps1

  1. <# 
  2. .SYNOPSIS 
  3.     Uses Win32_PNPEntity to return information about non-working devices.
  4. .DESCRIPTION 
  5.     This script calls Get-WmiObject to retrieve plug and play details,  
  6.     then formats and displays non-working devices. The script also has to 
  7.     work around how WMI returns 0 and 1 object (i.e. no $obj.count). 
  8.      
  9.     This is also sample 6 on http://msdn.microsoft.com/en-us/library/aa394587(VS.85).aspx 
  10.     recoded with PowerShell. 
  11. .NOTES 
  12.     File Name  : Get-NonWorkingDevices.ps1 
  13.     Author     : Thomas Lee - tfl@psp.co.uk 
  14.     Requires   : PowerShell V2 CTP3 
  15. .LINK 
  16.     Script posted to: 
  17.     http://www.pshscripts.blogspot.com 
  18.     Original MSDN Page 
  19.     http://msdn.microsoft.com/en-us/library/aa394587(VS.85).aspx 
  20. .EXAMPLE 
  21.     PS C:\foo> Get-NonWorkingDevices.ps1 
  22.     No bad devices on Cookham8 
  23. .EXAMPLE 
  24.     PS C:\foo> Get-NonWorkingDevices.ps1 
  25.     Total Bad devices on Cookham8: 1 
  26.     Name           : NETGEAR FA311v2 PCI Adapter - Virtual Network 
  27.     Class Guid     : {4d36e972-e325-11ce-bfc1-08002be10318} 
  28.     Description    : Microsoft Virtual Network switch Adapter 
  29.     Device ID      : ROOT\VMS_MP\0001 
  30.     Manufacturer   : 
  31.     PNP Device Id  : ROOT\VMS_MP\0001 
  32.     Service Name   : VMSMP 
  33. #> 
  34.  
  35. ### 
  36. #   Start of Script 
  37. ### 
  38.  
  39. # Get non-working devices: 
  40. $BadDevices = Get-WmiObject Win32_PNPEntity | Where {$_.ConfigManagerErrorcode -ne 0} 
  41.  
  42. # Display bad devices  
  43. $Hostname = Hostname 
  44. if (!$BadDevices) { 
  45.    "No bad devices on {0}" -f $Hostname 
  46. # end if 
  47. else
  48. if (!$BadDevices.Count) {$Count=1} else {$Count=$BadDevices.count} 
  49. "Total Bad devices on {0}: {1}" -f $Hostname, $Count 
  50. foreach ($Device in $BadDevices) { 
  51. "Name           : {0}" -f $Device.Name 
  52. "Class Guid     : {0}" -f $Device.Classguid 
  53. "Description    : {0}" -f $Device.Description 
  54. "Device ID      : {0}" -f $Device.Deviceid 
  55. "Manufacturer   : {0}" -f $Device.Manufactuer 
  56.  
  57. "PNP Device Id  : {0}" -f $Device.PNPDeviceID 
  58. "Service Name   : {0}" -f $Device.Service 
  59. "" 
  60. } # End of ForEach 
  61. # End of Else 

Saturday, 3 January 2009

Get-MouseInfo.ps1

  1. <# 
  2. .SYNOPSIS 
  3.     Uses Win32_PointingDevice WMI class to return Mouse details.     
  4. .DESCRIPTION 
  5.     This script first defines some functions to decode various  
  6.     WMI attributed from binary to text. Then the script calls  
  7.     Get-WmiObject to retrieve Mouse details, then formats that 
  8.     information (using the functions defined at the top of the script. 
  9.      
  10.     While on most systems, there is only one mouse, WMI can return
  11.     multiple devices. Hence the foreach loop. Thanks to Jeffrey
  12.     Snover for the tip-off!  Also note that not all properties
  13.     are returned – although mileage may vary.
  14.      
  15.     This is also sample 7 on http://msdn.microsoft.com/en-us/library/aa394587(VS.85).aspx 
  16.     recoded with PowerShell. 
  17. .NOTES 
  18.     File Name  : Get-Mouseinfo.ps1 
  19.     Author     : Thomas Lee - tfl@psp.co.uk 
  20.     Requires   : PowerShell V2 CTP3 
  21. .LINK 
  22.     Script posted to: 
  23.     http://www.pshscripts.blogspot.com 
  24.     Original MSDN Page 
  25.     http://msdn.microsoft.com/en-us/library/aa394587(VS.85).aspx 
  26. .EXAMPLE 
  27.     PS C:\foo> Get-Mouseinfo.ps1 
  28.     Mouse Information on System: COOKHAM8  (device 1)
  29.     Description            : PS/2 Compatible Mouse 
  30.     Device ID              : ACPI\PNP0F13\4&33DCE2F0&0 
  31.     Device Interface       : PS/2 
  32.     Double Speed Threshold : 
  33.     Handedness             : 
  34.     Hardware Type          : PS/2 Compatible Mouse 
  35.     INF File Name          : msmouse.inf 
  36.     Inf Section            : PS2_Inst 
  37.     Manufacturer           : Microsoft 
  38.     Name                   : PS/2 Compatible Mouse 
  39.     Number of buttons      : 0 
  40.     PNP Device ID          : ACPI\PNP0F13\4&33DCE2F0&0 
  41.     Pointing Type          : Unknown 
  42.     Quad Speed Threshold   : 
  43.     Resolution             : 
  44.     Sample Rate            : 
  45.     Synch                  : 
  46. #> 
  47.  
  48. ### 
  49. # Start of Script 
  50. ### 
  51.  
  52. # Functions to decode details 
  53.  
  54. function Deviceinterface { 
  55. param ($value) 
  56. switch ($value) { 
  57. 0    {"Other"
  58. 1    {"Unknown"
  59. 3    {"Serial"
  60. 4    {"PS/2"
  61. 5    {"Infrared"
  62. 6    {"HP-HIL"
  63. 7    {"Bus Mouse"
  64. 8    {"ADP (Apple Desktop Bus)"
  65. 160  {"Bus Mouse DB-9"
  66. 161  {"Bus Mouse Micro-DIN"
  67. 162  {"USB"
  68.  
  69. function Handedness { 
  70. param ($value) 
  71. switch ($value) { 
  72. 0 {"Unknown"
  73. 1 {"Not Applicable"
  74. 2 {"Right-Handed Operation"
  75. 3 {"Left-Handed Operation"
  76.  
  77. function Pointingtype { 
  78. param ($value) 
  79. switch ($value) { 
  80. 1 {"Other"
  81. 2 {"Unknown"
  82. 3 {"Mouse"
  83. 4 {"Track Ball"
  84. 5 {"Track Point"
  85. 6 {"Glide Point"
  86. 7 {"Touch Pad"
  87. 8 {"Touch Screen"
  88. 9 {"Mouse - Optical Sensor"
  89.  
  90. # Now do script stuff 
  91. # Get Mouse information 
  92. $mice = Get-WmiObject -Class Win32_PointingDevice 
  93. $i=1 
  94.  
  95. foreach ($mouse in $mice) { 
  96.  
  97. # Display details 
  98. "Mouse Information on System: {0} (device {1})" -f $mouse.systemname, $i 
  99. "Description            : {0}" -f $mouse.Description 
  100. "Device ID              : {0}" -f $mouse.DeviceID 
  101. "Device Interface       : {0}" -f (Deviceinterface($mouse.DeviceInterface)) 
  102. "Double Speed Threshold : {0}" -f $mouse.DoubleSpeedThreshold 
  103. "Handedness             : {0}" -f (Handedness($mouse.handedness)) 
  104. "Hardware Type          : {0}" -f $mouse.Hardwaretype 
  105. "INF File Name          : {0}" -f $mouse.InfFileName 
  106. "Inf Section            : {0}" -f $mouse.InfSection 
  107. "Manufacturer           : {0}" -f $mouse.Manufacturer 
  108. "Name                   : {0}" -f $mouse.Name 
  109. "Number of buttons      : {0}" -f $mouse.NumberOfButtons 
  110. "PNP Device ID          : {0}" -f $mouse.PNPDeviceID 
  111. "Pointing Type          : {0}" -f (Pointingtype ($mouse.PointingType)) 
  112. "Quad Speed Threshold   : {0}" -f $mouse.QuadSpeedThreshold 
  113. "Resolution             : {0}" -f $mouse.Resolution 
  114. "Sample Rate            : {0}" -f $mouse.SampleRate 
  115. "Synch                  : {0}" -f $mouse.Synch 
  116. $i++ 
  117. # End of Script