Re: DISC SPACE

Tech-Archive recommends: Fix windows errors by optimizing your registry



Mark D. MacLachlan wrote:

I would just use VBScript and WMI to gather the information.

[code]
'=====================================================================
== ===
'
' NAME: ReportServerDiskUtilization.vbs
'
' AUTHOR: Mark D. MacLachlan , The Spider's Parlor
' url: http://www.thespidersparlor.com
' DATE : 7/9/2009
' COPYRIGHT C 2009, All Rights Reserved
'
' COMMENT:
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
' ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
To ' THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
' PARTICULAR PURPOSE.
'
' IN NO EVENT SHALL THE SPIDER'S PARLOR AND/OR ITS RESPECTIVE
SUPPLIERS
' BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
ANY ' DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
PROFITS, ' WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ' ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE ' OF THIS CODE OR INFORMATION.
'
'=====================================================================
== ===
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set WshShell = CreateObject("WScript.Shell")
'Create our log
Set ts = objFSO.CreateTextFile("DiskUtilization.txt",True)

'Enum Servers In Domain
Set oRootDSE = GetObject("LDAP://rootDSE";)
strDom = oRootDSE.Get("DefaultNamingContext")

' available categories = computer, user, printqueue, group
qQuery = "<LDAP://"; & strDom & ">;" & _
"(objectCategory=computer)" & _
";name,operatingSystem;subtree"

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Open "Provider=ADsDSOObject;"
objCommand.ActiveConnection = objConnection
objCommand.CommandText = qQuery
Set objRecordSet = objCommand.Execute

Do until objRecordSet.EOF
If InStr(objRecordSet.Fields("operatingSystem"),"Server") > 1 Then
'Verify server is online first
strComputer = objRecordSet.Fields("name")
PingCheck = PingStatus(strComputer)
If PingCheck = "Success" Then
Report = GetServerDiskInfo(objRecordSet.Fields("name"))
Else
Report = strComputer & " is offline" & vbCrLf &
"******************************************" & vbCrLf

End If
PingCheck = ""
strComputer = ""
ts.Write Report
End If
objrecordset.MoveNext
loop
objConnection.Close
'Close the report file
ts.Close

WshShell.Run("notepad.exe DiskUtilization.txt")

WScript.Quit


Function PingStatus(strComputer)
On Error Resume Next
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer &
"\root\cimv2")
Set colPings = objWMIService.ExecQuery _
("SELECT * FROM Win32_PingStatus WHERE Address = '" &
strComputer & "'")
For Each objPing in colPings
Select Case objPing.StatusCode
Case 0 PingStatus = "Success"
Case Else PingStatus = "Offline"
End Select
Next
End Function


Function GetServerDiskInfo(strComputer)
'Now Get Disk Information For the Servers
'Bind to WMI on the target server
On Error Resume Next
Set objWMIService = GetObject("winmgmts:\\" & strComputer &
"\root\cimv2")
If Err.Number = 0 Then
report = report & strComputer & " Disk Drive Information" & vbCrLf &
"******************************************" & vbCrLf & vbCrLf
Set colItems = objWMIService.ExecQuery("Select * from
Win32_LogicalDisk where DriveType = '3'",,48)
For Each objItem in colItems
report = report & "Drive: " & objItem.Caption & vbCrLf
report = report & "VolumeSerialNumber: " &
objItem.VolumeSerialNumber& vbCrLf
report = report & "Description: " & objItem.Description& vbCrLf
report = report & "Size: " & objItem.Size /1024\1024+1 & "MB
Total Disk Space" & vbCrLf
report = report & "Free Space: " & objItem.FreeSpace
/1024\1024+1 & "MB Free Disk Space" & vbCrLf & vbCrLf
Next
Else
report = strComputer & " is unreachable via WMI" & vbCrLf &
"******************************************" & vbCrLf
End If
On Error Goto 0
GetServerDiskInfo = report
End Function

[/code]

Dangit, I hadn't refreshed my forum window and I see Richard already
posted a script. Looks like we are doing much the same thing except
mine will enumerate all servers in the domain without a source file.

--

.



Relevant Pages

  • Re: 4.4.7 NDRs on sent email - messages remain in STMP queue until expiry
    ... the free email servers seems very hit and miss. ... This issue occurs may because the Symantec Antivirus Corporate Edition ... Microsoft Exchange Server servers or on Microsoft Windows SMTP servers. ... Please collect the MPS Report for Exchange: ...
    (microsoft.public.windows.server.sbs)
  • Re: [Full-Disclosure] New malware to infect IIS and from there jump to clients
    ... >Microsoft teams are investigating a report of a security issue affecting ... >Microsoft Internet Explorer, components of Windows. ... >The malware spreads from infected IIS servers to clients that visit the ...
    (Full-Disclosure)
  • Re: Server Performance Report - Date Format
    ... standard UK format. ... If you want to change the Performance Report format on Server 4 to Standard ... DO NOT CHECK "Default user account settings" ... I receive Emailed Server Performance Reports from 4 Servers (different ...
    (microsoft.public.windows.server.sbs)
  • Re: Recovery via Unrecovery
    ... so preparing to roll out some updates to our main web servers. ... everything and report the results. ... Come the day of the switch, we had green lights reported from everyone. ... specific cow-orker's clients. ...
    (alt.sysadmin.recovery)
  • Re: Set folder date to newest file
    ... Mark D. MacLachlan wrote: ... the last modified date to the current date, but cannot "spoof" the date. ... Powershell is not installed on all my servers, and some servers are beyond my control. ...
    (microsoft.public.scripting.vbscript)