Skip to main content

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:
  1. navigate to %systemroot%\system32\wins
  2. stop the wins service: net stop wins
  3. run jetpack: jetpack wins.mdb tmp.mdb
  4. start the wins service: net start wins
tmp.mdb can be named anything. it's used to replace the existing file when it finishes. i'm seeing about a 50% reduction in size when i do this. coincidentally, it's the same thing for dhcp except you point it to %systemroot%\system32\dhcp and the dhcp.mdb file. i wrote up this little script to use in mom. depending on the parameters you give, it will check either the wins or the dhcp database to see if it's above 30mb. if it is, it'll create an event. the parameters you need are:
  • Database Type
  • LogSuccessEvent
for database type, you specify either wins or dhcp. logsuccessevent ... well... logs events if it is successful as well. :) view this is in internet explorer. firefox truncates the lines when i use "pre" tags. watch for word wrap as well. here it is anyway:
'==========================================================================
'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

Popular posts from this blog

using preloadpkgonsite.exe to stage compressed copies to child site distribution points

UPDATE: john marcum sent me a kind email to let me know about a problem he ran into with preloadpkgonsite.exe in the new SCCM Toolkit V2 where under certain conditions, packages will not uncompress.  if you are using the v2 toolkit, PLEASE read this blog post before proceeding.   here’s a scenario that came up on the mssms@lists.myitforum.com mailing list. when confronted with a situation of large packages and wan links, it’s generally best to get the data to the other location without going over the wire. in this case, 75gb. :/ the “how” you get the files there is really not the most important thing to worry about. once they’re there and moved to the appropriate location, preloadpkgonsite.exe is required to install the compressed source files. once done, a status message goes back to the parent server which should stop the upstream server from copying the package source files over the wan to the child site. anyway, if it’s a relatively small amount of packages, you can

How to Identify Applications Using Your Domain Controller

Problem Everyone has been through it. We've all had to retire or replace a domain controller at some point in our checkered collective experiences. While AD provides very intelligent high availability, some applications are just plain dumb. They do not observe site awareness or participate in locating a domain controller. All they want is the name or IP of one domain controller which gets hardcoded in a configuration file somewhere, deeply embedded in some file folder or setting that you are never going to find. How do you look at a DC and decide which applications might be doing it? Packet trace? Logs? Shut it down and wait for screaming? It seems very tedious and nearly impossible. Potential Solution Obviously I wouldn't even bother posting this if I hadn't run across something interesting. :) I ran across something in draftcalled Domain Controller Isolation. Since it's in draft, I don't know that it's published yet. HOWEVER, the concept is based off

sccm: content hash fails to match

back in 2008, I wrote up a little thing about how distribution manager fails to send a package to a distribution point . even though a lot of what I wrote that for was the failure of packages to get delivered to child sites, the result was pretty much the same. when the client tries to run the advertisement with an old package, the result was a failure because of content mismatch. I went through an ordeal recently capturing these exact kinds of failures and corrected quite a number of problems with these packages. the resulting blog post is my effort to capture how these problems were resolved. if nothing else, it's a basic checklist of things you can use.   DETECTION status messages take a look at your status messages. this has to be the easiest way to determine where these problems exist. unfortunately, it requires that a client is already experiencing problems. there are client logs you can examine as well such as cas, but I wasn't even sure I was going to have enough m