Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

What is the free space a machine is having in the file

Posted on 2007-08-08
9
Medium Priority
?
275 Views
Last Modified: 2010-03-05
Hi,

I have a file which has all the machine names .Is there a way to find the free space a machine is available with. On all the drives available in the machine.

Regards
Sharath
0
Comment
Question by:bsharath
9 Comments
 

Expert Comment

by:davidrivers
ID: 19655204
Probally not from the hostname; if the machines have Windows XP or Have the terminal services client / remote administration then you could logon as the domain administrator or a local administrator and manually check each machine.

The other option would require asset software to be installed on the client machines.

Please provide further information are all machines running WIndows XP and are they on a Domain? If they are then I can come up with a solution via installed software and running it via a logon script
0
 
LVL 18

Expert Comment

by:chuckyh
ID: 19655259
You really need SMS from what I can tell based on all the questions you have been asking.
0
 
LVL 11

Author Comment

by:bsharath
ID: 19655285
chuckyh:

General Question.

Have you installed SMS.Is it very touch to set it up.I am planning to install but wanted an expert to give me some suggestions to my Questions before i get started...
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 5

Expert Comment

by:ardrac
ID: 19655389
I do agree that you should be looking at some form of system & Asset management software.

Having said that what you want is possible.

The following WMI script if run on a local computer will give you the drive name for all local hard drives and the ammount of free space on each.

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colDiskDrives = objWMIService.ExecQuery _
    ("Select * from Win32_PerfFormattedData_PerfDisk_LogicalDisk Where " _
        & "Name <> '_Total'")

For Each objDiskDrive in colDiskDrives
    Wscript.Echo "Drive Name: " & objDiskDrive.Name
    Wscript.Echo "Free Space: " & objDiskDrive.FreeMegabytes
Next


If you change strComputer = "." to be a remote computers name then it will report on that.

So all you now need to do is read each machine name from a file and use the machine name as StrComputer. Also need to point the script to a results.txt file and write the results to that rather then just wscript.echo. You may be able to modify other scripts you have to acheive that. If you can not then shout and I will try write it for you but That may not be for a couple of days.

hope it helps
0
 
LVL 14

Expert Comment

by:canali
ID: 19655417

' get-free-space-all-PCs.vbs
' read the computer computers list from the file c:\computers.txt
' for get output on file run:
' cscript //nologo get-free-space-all-PCs.vbs >result.txt
'
'
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.FreeSpace
    Next
  else
    getinfo="Error computer not found"
    err.clear
  end if
  WScript.echo strComputer & space(10-len(strComputer)) &": " & getinfo
end sub
0
 
LVL 14

Expert Comment

by:canali
ID: 19655509
'
' get-free-space-all-PCs.vbs
' read the computer computers list from the file c:\computers.txt
' for get output on file run:
' cscript //nologo get-free-space-all-PCs.vbs >result.txt
' with output in megabytes
'
Const ForReading = 1
Const CONVERSION_FACTOR = 1048576
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 &" " & round(objInstance.FreeSpace/conversion_factor,0) &" MB"
    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: 19655526
I get this.

hydsophos :  C: 8414646784 D: 80750157824
Can you change the output as 20 GB.Is this showing free space ?
0
 
LVL 11

Author Comment

by:bsharath
ID: 19655547
Thanks ....
When it is GB can it show GB instead of MB
0
 
LVL 14

Accepted Solution

by:
canali earned 2000 total points
ID: 19655805
'
' get-free-space-all-PCs.vbs
' read the computer computers list from the file c:\computers.txt
' for get output on file run:
' cscript //nologo get-free-space-all-PCs.vbs >result.txt
' GIGA
'
Const ForReading = 1
'megabytes
'Const CONVERSION_FACTOR = 1048576
'gigabytes
Const CONVERSION_FACTOR = 1073741824
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 &" " & round(objInstance.FreeSpace/conversion_factor,2) &" GB"
    Next
  else
    getinfo="Error computer not found"
    err.clear
  end if
  WScript.echo strComputer & space(10-len(strComputer)) &": " & getinfo
end sub
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Some time ago I faced the need to use a uniform folder structure that spanned across numerous sites of an enterprise to be used as a common repository for the Software packages of the Configuration Manager 2007 infrastructure. Because the procedu…
Many admins will agree: WSUS is is a nice invention but using it on the client side when updating a newly installed computer is still time consuming as you have to do several reboots and furthermore, the procedure of installing updates, rebooting a…
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…
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

578 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