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. } 
  70.  
  71. function Handedness { 
  72. param ($value) 
  73. switch ($value) { 
  74. 0 {"Unknown"} 
  75. 1 {"Not Applicable"} 
  76. 2 {"Right-Handed Operation"} 
  77. 3 {"Left-Handed Operation"} 
  78. } 
  79. } 
  80.  
  81. function Pointingtype { 
  82. param ($value) 
  83. switch ($value) { 
  84. 1 {"Other"} 
  85. 2 {"Unknown"} 
  86. 3 {"Mouse"} 
  87. 4 {"Track Ball"} 
  88. 5 {"Track Point"} 
  89. 6 {"Glide Point"} 
  90. 7 {"Touch Pad"} 
  91. 8 {"Touch Screen"} 
  92. 9 {"Mouse - Optical Sensor"} 
  93. } 
  94. } 
  95.  
  96. # Now do script stuff 
  97. # Get Mouse information 
  98. $mice = Get-WmiObject -Class Win32_PointingDevice 
  99. $i=1 
  100.  
  101. foreach ($mouse in $mice) { 
  102.  
  103. # Display details 
  104. "Mouse Information on System: {0} (device {1})" -f $mouse.systemname, $i 
  105. "Description            : {0}" -f $mouse.Description 
  106. "Device ID              : {0}" -f $mouse.DeviceID 
  107. "Device Interface       : {0}" -f (Deviceinterface($mouse.DeviceInterface)) 
  108. "Double Speed Threshold : {0}" -f $mouse.DoubleSpeedThreshold 
  109. "Handedness             : {0}" -f (Handedness($mouse.handedness)) 
  110. "Hardware Type          : {0}" -f $mouse.Hardwaretype 
  111. "INF File Name          : {0}" -f $mouse.InfFileName 
  112. "Inf Section            : {0}" -f $mouse.InfSection 
  113. "Manufacturer           : {0}" -f $mouse.Manufacturer 
  114. "Name                   : {0}" -f $mouse.Name 
  115. "Number of buttons      : {0}" -f $mouse.NumberOfButtons 
  116. "PNP Device ID          : {0}" -f $mouse.PNPDeviceID 
  117. "Pointing Type          : {0}" -f (Pointingtype ($mouse.PointingType)) 
  118. "Quad Speed Threshold   : {0}" -f $mouse.QuadSpeedThreshold 
  119. "Resolution             : {0}" -f $mouse.Resolution 
  120. "Sample Rate            : {0}" -f $mouse.SampleRate 
  121. "Synch                  : {0}" -f $mouse.Synch 
  122. $i++ 
  123. } 
  124. # End of Script