- <#
- .SYNOPSIS
- Uses Win32_PNPEntity to return information about non-working devices.
- .DESCRIPTION
- This script calls Get-WmiObject to retrieve plug and play details,
- then formats and displays non-working devices. The script also has to
- work around how WMI returns 0 and 1 object (i.e. no $obj.count).
- This is also sample 6 on http://msdn.microsoft.com/en-us/library/aa394587(VS.85).aspx
- recoded with PowerShell.
- .NOTES
- File Name : Get-NonWorkingDevices.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-NonWorkingDevices.ps1
- No bad devices on Cookham8
- .EXAMPLE
- PS C:\foo> Get-NonWorkingDevices.ps1
- Total Bad devices on Cookham8: 1
- Name : NETGEAR FA311v2 PCI Adapter - Virtual Network
- Class Guid : {4d36e972-e325-11ce-bfc1-08002be10318}
- Description : Microsoft Virtual Network switch Adapter
- Device ID : ROOT\VMS_MP\0001
- Manufacturer :
- PNP Device Id : ROOT\VMS_MP\0001
- Service Name : VMSMP
- #>
- ###
- # Start of Script
- ###
- # Get non-working devices:
- $BadDevices = Get-WmiObject Win32_PNPEntity | Where {$_.ConfigManagerErrorcode -ne 0}
- # Display bad devices
- $Hostname = Hostname
- if (!$BadDevices) {
- "No bad devices on {0}" -f $Hostname
- } # end if
- else {
- if (!$BadDevices.Count) {$Count=1} else {$Count=$BadDevices.count}
- "Total Bad devices on {0}: {1}" -f $Hostname, $Count
- foreach ($Device in $BadDevices) {
- "Name : {0}" -f $Device.Name
- "Class Guid : {0}" -f $Device.Classguid
- "Description : {0}" -f $Device.Description
- "Device ID : {0}" -f $Device.Deviceid
- "Manufacturer : {0}" -f $Device.Manufactuer
- "PNP Device Id : {0}" -f $Device.PNPDeviceID
- "Service Name : {0}" -f $Device.Service
- ""
- } # End of ForEach
- } # End of Else
This blog contains PowerShell scripts, more PowerShell scripts and still more PowerShell scripts. Occasionally you may see some organisational posts.
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
Labels:
powershell,
PowerShell scripts,
Win32_PointingDevice,
wmi
Saturday, 3 January 2009
Get-MouseInfo.ps1
- <#
- .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
Labels:
PowerShell scripts,
PowerShell V2,
Win32_PointingDevice,
wmi
Subscribe to:
Posts (Atom)