?
Solved

Get all the machines volume label names to a file

Posted on 2007-08-10
6
Medium Priority
?
346 Views
Last Modified: 2010-03-05
Hi,

I want to get all the volume label names to a file.I have all the machine names in a txt file.Need a script to scan the machines and get all the drives label names.

Machinename   C: Labelname   D:  Labelname and so on.

Regards
Sharath
0
Comment
Question by:bsharath
6 Comments
 
LVL 13

Expert Comment

by:hiteshgoldeneye
ID: 19675195
0
 
LVL 14

Expert Comment

by:canali
ID: 19675270
'
' get-HD-label-all-PCs.vbs
' read the computer computers list from the file c:\computers.txt
' for get output on file run:
'
' cscript //nologo get-HD-label-all-PCs.vbs >result.txt
'
' Gastone Canali
'
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\Computers.txt", ForReading)
do while not objFile.AtEndOfStream
    PC = objFile.ReadLine
    Gethdinfo (PC)
loop
objFile.Close
sub Gethdinfo(strComputer)
  getinfo=""
  On Error Resume Next
  Set objWMIService = GetObject( "winmgmts://" & strComputer & "/root/CIMV2" )
  Set colInstances = objWMIService.ExecQuery( "SELECT * FROM Win32_LogicalDisk where driveType=3",  "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly )
  If Err.Number = 0 then
    For Each objInstance In colInstances
          getinfo=getinfo & " " & objInstance.deviceID &" " & objInstance.volumename  
    Next
  else
    getinfo="Error computer not found"
    err.clear
  end if
  WScript.echo strComputer & space(10-len(strComputer)) &": " & getinfo
end sub
0
 
LVL 11

Author Comment

by:bsharath
ID: 19675452
I tried tha same way as mentioned.TRhe file is creating but no data in the results.txt
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 14

Expert Comment

by:canali
ID: 19676048
try only:
cscript //nologo get-HD-label-all-PCs.vbs
0
 
LVL 11

Author Comment

by:bsharath
ID: 19676223
C:\>cscript //nologo get-HD-label-all-PCs.vbs
hydsophos :  C:  D: Data
          : Error computer not found
          : Error computer not found
          : Error computer not found
0
 
LVL 26

Accepted Solution

by:
Farhan Kazi earned 2000 total points
ID: 19676300
:: ================
:: 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 "VolLblRpt.rtf" 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:\VolLblRpt.rtf DEL /F /Q C:\VolLblRpt.rtf

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 (
            SET Qry=WMIC /NODE:"%%c" LOGICALDISK GET DeviceID,VolumeName ^| Find ":"
            Echo Machine Name: %%c >>C:\VolLblRpt.rtf
            FOR /F "Skip=1 Tokens=1-2" %%d IN ('!Qry!') DO Echo %%d %%e >>C:\VolLblRpt.rtf
      )ELSE (Echo %%c: Not able to connect >>C:\VolLblRpt.rtf)
)      

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

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

My previous article  (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/Server/Windows_Server_2008/A_4466-A-beginners-guide-to-installing-SCCM2007-on-Windows-2008-R2-Server.html)detailed one possible method to get SCCM 2007 installed an…
Remote Apps is a feature in server 2008 which allows users to run applications off Remote Desktop Servers without having to log into them to run the applications.  The user can either have a desktop shortcut installed or go through the web portal to…
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…
Suggested Courses

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question