• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 228
  • Last Modified:

Find all com prrts usb ports etc

Hi,

I want a script which can get all the Com,USB,VGA,Ps2, and any other ports a machine has.

All the data to a csv file.With header of any available ports...

I have all machine names in a file.

Regards
Sharath
0
bsharath
Asked:
bsharath
  • 4
  • 4
1 Solution
 
Farhan KaziSystems EngineerCommented:
:: ================
:: READ THIS FIRST
:: ================
:: * To run this script you must have domain administrators rights.
:: * This script require "Computers.txt" file on C: drive root from where it will pick computer names.
:: * Successful run will generate "SystemName_Ports.csv" on C: drive root.
:: * Copy and Paste following script into notepad and save it with any name having .bat extension.
:: Batch Script Start

@Echo Off
SETLOCAL EnableDelayedExpansion

IF NOT EXIST C:\Computers.txt Goto ShowErr
FOR %%R IN (C:\Computers.txt) Do IF %%~zR EQU 0 Goto ShowErr
FOR /F %%c IN ('Type Computers.txt') Do (
    Echo Processing: %%c
      PING -n 1 -w 1000 %%c|Find /I "TTL" >NUL
      IF NOT ErrorLevel 1 (
            WMIC /NODE:"%%c" PORTCONNECTOR GET ExternalReferenceDesignator >C:\%%c_Ports.csv
      )ELSE (Echo %%c: Not able to connect)
)      

Goto EndScript
:ShowErr
Echo "C:\Computers.txt" file does not exist or file is empty!
:EndScript
ENDLOCAL
:: Batch Script End
0
 
bsharathAuthor Commented:
I get this.

ExternalReferenceDesignator  
COM 1                        
Parallel                    
Keyboard                    
PS/2 Mouse                  


But no usb?
And i dont get info for Rack servers
It just shows this.
ExternalReferenceDesignator  

Can you put all results in 1 file instead of each file for each machine.
0
 
Farhan KaziSystems EngineerCommented:
:: ================
:: READ THIS FIRST
:: ================
:: * To run this script you must have domain administrators rights.
:: * This script require "Computers.txt" file on C: drive root from where it will pick computer names.
:: * Following script requires 'Devcon.exe' on same path from where this script required to be run
::    'Devcon.exe' can be freely be downloaded from following site:
::     http://support.microsoft.com/kb/311272
:: * Successful run will generate "SystemPorts.txt" on C: drive root.
:: * Copy and Paste following script into notepad and save it with any name having .bat extension.
:: Batch Script Start

@Echo Off
SETLOCAL EnableDelayedExpansion

IF NOT EXIST C:\Computers.txt Goto ShowErr
FOR %%R IN (C:\Computers.txt) Do IF %%~zR EQU 0 Goto ShowErr
IF EXIST C:\SystemPorts.txt DEL /F /Q C:\SystemPorts.txt

FOR /F %%c IN ('Type Computers.txt') Do (
    Echo Processing: %%c
      PING -n 1 -w 1000 %%c|Find /I "TTL" >NUL
      IF NOT ErrorLevel 1 (
                  Echo ----------------- >>C:\SystemPorts.txt
                  Echo %%c >>C:\SystemPorts.txt            
                  Echo ----------------- >>C:\SystemPorts.txt
                  SET Qry=Devcon -m:\\%%c ListClass Display Ports USB Keyboard Mouse
                  FOR /F "Delims=: Tokens=2" %%H IN ('!Qry!') Do (@Echo %%H >>C:\SystemPorts.txt)
      )ELSE (
        Echo ----------------- >>C:\SystemPorts.txt
        Echo %%c: Not able to connect >>C:\SystemPorts.txt
        Echo ----------------- >>C:\SystemPorts.txt)
)      

Goto EndScript
:ShowErr
Echo "C:\Computers.txt" file does not exist or file is empty!
:EndScript
ENDLOCAL
:: Batch Script EndServer                               
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

 
bsharathAuthor Commented:
Farhan
I get this.

-----------------
hydsophos            
-----------------
 RADEON 7000 SERIES      
 Communications Port (COM1)
 Intel(R) 82801EB USB Universal Host Controller - 24D2
 Intel(R) 82801EB USB Universal Host Controller - 24D4
 Intel(R) 82801EB USB Universal Host Controller - 24D7
 Intel(R) 82801EB USB2 Enhanced Host Controller - 24DD
 USB Root Hub
 USB Root Hub
 USB Root Hub
 USB Root Hub
 USB Composite Device
 USB Composite Device
 Generic USB Hub
 HID Keyboard Device
 HID Keyboard Device
 HID-compliant mouse
 HID-compliant mouse
-----------------
Indiasophos            
-----------------
 RADEON 7000 SERIES      
 LogMeIn Mirror Driver
 Communications Port (COM1)
 Intel(R) 82801EB USB Universal Host Controller - 24D2
 Intel(R) 82801EB USB Universal Host Controller - 24D4
 Intel(R) 82801EB USB Universal Host Controller - 24D7
 Intel(R) 82801EB USB2 Enhanced Host Controller - 24DD
 USB Root Hub
 USB Root Hub
 USB Root Hub
 USB Root Hub
 USB Composite Device
 Generic USB Hub
 HID Keyboard Device
 HID-compliant mouse
-----------------
dev-chen-mrd100            
-----------------
 Standard VGA Graphics Adapter
 LogMeIn Mirror Driver
 ECP Printer Port (LPT1)
 Communications Port (COM1)
 Standard Universal PCI to USB Host Controller
 Standard Universal PCI to USB Host Controller
 Standard Universal PCI to USB Host Controller
 Standard Universal PCI to USB Host Controller
 Standard Enhanced PCI to USB Host Controller
 USB Root Hub
 USB Root Hub
 USB Root Hub
 USB Root Hub
 USB Root Hub
 Standard 101/102-Key or Microsoft Natural PS/2 Keyboard
 PS/2 Compatible Mouse

What does these mean...
0
 
Farhan KaziSystems EngineerCommented:
Perfect, it shows number of ports that are enabled (Bios) on system. First is shows Display Card, COM and LPT Ports,  USB Ports, Keyboard and Mouse.
0
 
bsharathAuthor Commented:
Now how should i count how many usb's are there in Dev-chen-mrd100..
0
 
Farhan KaziSystems EngineerCommented:
Above script depicts the information of Device Manager, to verify go to the 'Dev-chen-mrd100' and follow these steps.

    * Right-click My Computer
    * Click on Properties
    * Click on the Hardware tab
    * Click on the device Manager button
    * Scroll down as needed until you see Universal Serial Bus Controllers
    * Expand that by clicking on the boxed plus sign in front of Universal Serial Bus Controllers
0
 
bsharathAuthor Commented:
Farhan this is a nice one.If you can change this script a bit i shall raise a new Q.
Machinename   Com port   VGA  LPT   USB  
Dev-chen-mrd100   1          1       1        4
Is there a way to do this.

Please let me know i shall raise a Q....
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now