ds: compacting the wins database...
i have been terrible about compacting the wins database. i think about it so infrequently. it's definitely the last thing on my mind. well, according to microsoft, you should compact your wins database when it grows over 30mb. well, it's time. if you want details on jetpack, here's the article. otherwise, here's a short summary:
- navigate to %systemroot%\system32\wins
- stop the wins service: net stop wins
- run jetpack: jetpack wins.mdb tmp.mdb
- start the wins service: net start wins
- Database Type
- LogSuccessEvent
'==========================================================================
'NAME : MOM_WINSDHCP.vbs
'AUTHOR : Marcus C. Oh
'DATE : 12/28/2006
'COMMENT : Checks the WINS or DHCP database file size to determine if it
' needs to be compacted.
'==========================================================================
' Standard Event Type Numeric Values
Const EVENT_TYPE_SUCCESS = 0
Const EVENT_TYPE_ERROR = 1
Const EVENT_TYPE_WARNING = 2
Const EVENT_TYPE_INFORMATION = 4
sComputer = "."
Set oShell = CreateObject("WScript.Shell")
Set oFSO = CreateObject("Scripting.FileSystemObject")
sSystemRoot = oShell.ExpandEnvironmentStrings("%SystemRoot%")
sSystemRoot = Left(sSystemRoot,InStr(sSystemRoot,"\")) & Mid(sSystemRoot,InStr(sSystemRoot,"\"))
'Retrieve MOM script parameters -------------------------------------------
sType = ScriptContext.Parameters.Get("Database Type")
bLogSuccessEvent = CBool(ScriptContext.Parameters.Get("LogSuccessEvent"))
If LCase(sType) = "dhcp" Then
DHCPCheck
ElseIf LCase(sType) = "wins" Then
WINSCheck
Else
CreateEvent 41004,EVENT_TYPE_WARNING,"WINS_DHCP Script","Incorrect script parameter. Please specify either DHCP or WINS."
End If
'Check the WINS database file size ----------------------------------------
Sub WINSCheck
If oFSO.FileExists(sSystemRoot & "\system32\wins\wins.mdb") Then
Set oWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & sComputer & "\root\cimv2")
Set cFiles = oWMIService.ExecQuery("Select * from CIM_Datafile Where name = '"& sSystemRoot & "\\system32\\wins\\wins.mdb'")
For Each oFile in cFiles
If oFile.FileSize > 31450287 Then
CreateEvent 41006,EVENT_TYPE_ERROR,"WINS_DHCP Script","WINS.MDB needs to be compacted. Current size: " & oFile.FileSize & " bytes."
Else
If bLogSuccessEvent Then
CreateEvent 41005,EVENT_TYPE_INFORMATION,"WINS_DHCP Script","WINS.MDB does not need to be compacted. Size is " & oFile.FileSize & " bytes."
End If
End If
Next
End If
End Sub
'Check the WINS database file size ----------------------------------------
Sub DHCPCheck
If oFSO.FileExists(sSystemRoot & "\system32\dhcp\dhcp.mdb") Then
Set oWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & sComputer & "\root\cimv2")
Set cFiles = oWMIService.ExecQuery("Select * from CIM_Datafile Where name = '"& sSystemRoot & "\\system32\\dhcp\\dhcp.mdb'")
For Each oFile in cFiles
If oFile.FileSize > 31450287 Then
CreateEvent 41006,EVENT_TYPE_ERROR,"WINS_DHCP Script","DHCP.MDB needs to be compacted. Current size: " & oFile.FileSize & " bytes."
Else
If bLogSuccessEvent Then
CreateEvent 41005,EVENT_TYPE_INFORMATION,"WINS_DHCP Script","DHCP.MDB does not need to be compacted. Size is " & oFile.FileSize & " bytes."
End If
End If
Next
End If
End Sub
'Standard event subroutine for MOM ----------------------------------------
Sub CreateEvent(iEventNumber,iEventType,sEventSource,sEventMessage)
Set oEvent = ScriptContext.CreateEvent()
oEvent.EventNumber = iEventNumber
oEvent.EventType = iEventType
oEvent.EventSource = sEventSource
oEvent.Message = sEventMessage
ScriptContext.Submit oEvent
End Sub
Comments
Post a Comment