This is a basic script for retrieving hard disk information for a single computer.
Below VB Script will input for a computer name and will then retrieve Hard disk information of the computer. Output will be saved to a text file in C drive c:\Output.txt
VBSCRIPT:
' SCRIPT TO GET HARD DISK INFORMATION FOR A SINGLE COMPUTER
On Error Resume Next
Dim strComputer, ObjWMIService, ColItems
Dim fsoObject, open_file
strComputer = inputbox ("Script to retrieve disk information"_
,"VBSCRIPT"," Enter computer name here" )
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_LogicalDisk WHERE DriveType=3" )
Set fsoObject = WScript.CreateObject("Scripting.FileSystemObject")
Set open_file = fsoObject.OpenTextFile("c:\Output.txt", 8 , "True")
For Each objItem In colItems
open_file.WriteLine ("SystemName: " & vbtab & objItem.systemName)
open_file.WriteLine ("System Drive: " & vbtab & objItem.Name)
open_file.WriteLine ("FileSystem: " & vbtab & objItem.FileSystem)
open_file.WriteLine ("FileSize: " & vbtab & (objItem.Size)/1073741824) & " GB"
open_file.WriteLine ("FreeSpace: " & vbtab & (objItem.FreeSpace)/1073741824) & " GB"
open_file.WriteLine ("FreeSpace % : " & vbtab & INT((objItem.FreeSpace / objItem.Size) * 1000)/10 )
open_file.WriteLine ("***********************************")
Next
open_file.Close()
INPUT: Your Input Window will appear as below
OUTPUT: This is your Output saved to your Text file
Below VB Script will input for a computer name and will then retrieve Hard disk information of the computer. Output will be saved to a text file in C drive c:\Output.txt
VBSCRIPT:
' SCRIPT TO GET HARD DISK INFORMATION FOR A SINGLE COMPUTER
On Error Resume Next
Dim strComputer, ObjWMIService, ColItems
Dim fsoObject, open_file
strComputer = inputbox ("Script to retrieve disk information"_
,"VBSCRIPT"," Enter computer name here" )
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_LogicalDisk WHERE DriveType=3" )
Set fsoObject = WScript.CreateObject("Scripting.FileSystemObject")
Set open_file = fsoObject.OpenTextFile("c:\Output.txt", 8 , "True")
For Each objItem In colItems
open_file.WriteLine ("SystemName: " & vbtab & objItem.systemName)
open_file.WriteLine ("System Drive: " & vbtab & objItem.Name)
open_file.WriteLine ("FileSystem: " & vbtab & objItem.FileSystem)
open_file.WriteLine ("FileSize: " & vbtab & (objItem.Size)/1073741824) & " GB"
open_file.WriteLine ("FreeSpace: " & vbtab & (objItem.FreeSpace)/1073741824) & " GB"
open_file.WriteLine ("FreeSpace % : " & vbtab & INT((objItem.FreeSpace / objItem.Size) * 1000)/10 )
open_file.WriteLine ("***********************************")
Next
open_file.Close()
INPUT: Your Input Window will appear as below
OUTPUT: This is your Output saved to your Text file
No comments:
Post a Comment