bsharath
asked on
What is the free space a machine is having in the file
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
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
You really need SMS from what I can tell based on all the questions you have been asking.
ASKER
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...
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...
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=imper sonate}!\\ " & strComputer & "\root\cimv2")
Set colDiskDrives = objWMIService.ExecQuery _
("Select * from Win32_PerfFormattedData_Pe rfDisk_Log icalDisk 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
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=imper
Set colDiskDrives = objWMIService.ExecQuery _
("Select * from Win32_PerfFormattedData_Pe
& "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
' 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
'
'
Const ForReading = 1
Set objFSO = CreateObject("Scripting.Fi
Set objFile = objFSO.OpenTextFile("C:\Co
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))
end sub
'
' 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.Fi leSystemOb ject")
Set objFile = objFSO.OpenTextFile("C:\Co mputers.tx t", 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.FreeSpac e/conversi on_factor, 0) &" MB"
Next
else
getinfo="Error computer not found"
err.clear
end if
WScript.echo strComputer & space(10-len(strComputer)) &": " & getinfo
end sub
' 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
' with output in megabytes
'
Const ForReading = 1
Const CONVERSION_FACTOR = 1048576
Set objFSO = CreateObject("Scripting.Fi
Set objFile = objFSO.OpenTextFile("C:\Co
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.FreeSpac
Next
else
getinfo="Error computer not found"
err.clear
end if
WScript.echo strComputer & space(10-len(strComputer))
end sub
ASKER
I get this.
hydsophos : C: 8414646784 D: 80750157824
Can you change the output as 20 GB.Is this showing free space ?
hydsophos : C: 8414646784 D: 80750157824
Can you change the output as 20 GB.Is this showing free space ?
ASKER
Thanks ....
When it is GB can it show GB instead of MB
When it is GB can it show GB instead of MB
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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