O R G A N I C / F E R T I L I Z E R: 12.06

Dec 28, 2006

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

misc: thanks eventid.net!

for those of you that are MVPs, the kind folks at eventid.net have once again renewed my one year subscription. for those of that are you not, eventid.net is an excellent resource when you want to find information relevant to event IDs.

Dec 27, 2006

mom: monitoring adam

this just came across. i thought it was interesting for anyone that is interested in monitoring adam. i haven't looked at it yet... i don't really have any adam instances to monitor. anyway, it's a free mp from quest. check it out: http://www.quest.com/management_pack_for_adam/.

Dec 21, 2006

sms: serial numbers with warranty expiration...

here's something fun to try over the holiday season. marry up serial numbers that you're already collecting from your dell systems and join them to expiration warranty data so that you can see when your systems will go out of warranty. anyway, i'm sure someone very versed in sql scripting can come up with something better than what i've illustrated. i'm using stock scripts from query analyzer. remember, this is completely unsupported by microsoft. :) there are a few things you're going to need to get this started:
  1. a csv containing serial numbers and warranty
  2. a new table to hold the information
  3. a view for the new table
  4. a method to get the information into the table
  5. a report to look at all the new data
for the csv, you're going to need to get this data from dell (or from whatever manufacturer you use). basically, you'll want the format to look like this:
ABC1234,12/04/2009
ABC2234,12/04/2008
...

on your sms server, create a new table. if you're going to use my script to push the data in, then create one like this:

column name         data type
--------------      -------------
SerialNumber        nvarchar(50)
ExpirationDate      smalldatetime 
 
note, in the above, you do not want to allow nulls. you also want to set the primary key on SerialNumber since theoretically it should be unique. you could also use this little sql script to create it.
 
SET ANSI_NULLS ON 
GO 
SET QUOTED_IDENTIFIER ON 
GO

CREATE TABLE [dbo].[DellWarranty]([SerialNumber] [nvarchar](50) 
COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, 
[ExpirationDate] [smalldatetime] NOT NULL, 
CONSTRAINT [PK_DellWarranty] 
PRIMARY KEY CLUSTERED ( [SerialNumber] ASC )WITH 
(PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY] ) ON [PRIMARY] 
 

now that we have a table to work with, we'll create a view so that things are like the way sms does it. here's a sql script to run that will create a view called v_R_DellWarranty:

SET ANSI_NULLS ON 
GO 
SET QUOTED_IDENTIFIER ON 
GO 
CREATE VIEW [dbo].[v_R_DellWarranty] AS 
SELECT SerialNumber, ExpirationDate FROM dbo.DellWarranty
 

once your table and view is setup, apply the proper permission. i've outlined it in this blog post: sms: adjust permissions when using new tables... let's get the data into the table. once you have your .csv file ready, rename it to serials.csv and place it in c:\temp. why? because i'm lazy and haven't updated the script.

modify the following values so that you can connect to the sms server:

  • "Server=SMSSERVER;" &_
  • "Database=SMSDB;" &_
  • Set oTextFile = oFSO.OpenTextFile("C:\temp\serials.csv", 1) - this is the file and location

here's the script you're going to need:

Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oTextFile = oFSO.OpenTextFile("C:\temp\serials.csv", 1)

Set oConnection = CreateObject("ADODB.Connection")
oConnection.ConnectionString = _
    "Driver={SQL Server};" &_
    "Server=<YOUR SMS SERVER>;" &_ 
    "Database=<YOUR SMS DATABASE>;" &_
    "Trusted_Connection=yes;"

oConnection.Open

Do While oTextFile.AtEndOfStream <> True
    sLine = oTextFile.ReadLine
    If inStr(sLine, ",") Then
        aSerialRecord = Split(sLine, ",")
        sQuery =    "INSERT INTO DellWarranty(SerialNumber,ExpirationDate) " &_
                    "VALUES('" & Trim(aSerialRecord(0)) & "','" & Trim(aSerialRecord(1)) & "')"
        oConnection.Execute sQuery
      End If
Loop

oConnection.Close
 
once you run that, you'll have values populated into your new table. here's a sql query that you can create a sms report with. it's just a small example of how to use this new data:
 
select SYS.Name0 AS [System], CS.Model0 AS [Model], SerialNumber0 AS [Serial],
       Convert(CHAR(11),ExpirationDate,111) AS [Expiration]
from   v_R_System SYS INNER JOIN
       v_GS_System_Enclosure SE ON SYS.ResourceID = SE.ResourceID INNER JOIN
       v_GS_Computer_System CS ON SYS.ResourceID = CS.ResourceID INNER JOIN
       v_R_DellWarranty DW ON SE.SerialNumber0 = DW.SerialNumber 
order by [System]

Dec 19, 2006

misc: atlanta smug coming up 1/31/07

southeast management user group it's that time again. i've put the agenda below and have provided the links to the event registration. hope to see you there! Event Overview 9:00-10:30 Technical discussion regarding Microsoft’s Desktop Optimization Pack and integration points with System Management Server (SMS) 2003 Service Pack 3 • Application Virtualization with Microsoft SoftGrid • Microsoft Asset Inventory Service • Microsoft Disaster Recovery Toolset • Microsoft Advance Group Policy Management 10:30-10:45 Break 10:45-12:00 Monitoring .NET Applications with Microsoft Operations Manager (MOM) & Avicode 12:00-1:00 Working Lunch Managing Mobile Devices with SMS 2003 & Odyssey Software 1:00-2:30 Monitoring SAP with Microsoft Operations Manager (MOM) & Tidalsoft 2:30-2:45 Break 2:45-3:30 SMS & MOM Top 10 issues delivered by PSS registration links: January 24th 2007 Event Title : Charlotte Southeast IT Management Meeting Event ID : 1032321549 http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032321549&Culture=en-US January 31st 2007 Event Title : Atlanta Southeast IT Management Meeting Event ID : 1032321546 http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032321546&Culture=en-US February 27th 2007 Event Title : Raleigh Southeast IT Management Meeting Event ID : 1032321551 http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032321551&Culture=en-US

Dec 12, 2006

miis: attribute not defined as source exception

i ran into this error recently which the fine folks @ mmsug@yahoogroups.com helped me clear up. i didn't find but one reference while googling. even though the reference was right, it made so sense to me. no surprise right? here's the error:
Microsoft.MetadirectoryServices.AttributeNotDefinedAsSourceException: Attribute "myAttribute" is not declared as a dependency. at Microsoft.MetadirectoryServices.Impl.MVEntryImpl.get_Item(String attributeName) at Mms_ManagementAgent_CCI_MA.MAExtensionObject.MapAttributesForExport(String FlowRuleName, MVEntry mventry, CSEntry csentry)
i was goofing around with this sample code. the only thing i did was wrap an additional logic to check myAttribute to see if it needed to be processed at all. basically if myAttribute is marked to a value of "A" then do not process the user object under any circumstances. it seems the problem is that i didn't bother to include myAttribute as part of the flow going through the rule extension. i was flowing employeeStatus to userAccountControl but didn't bother to include myAttribute. in identity manager, i needed to ctrl-click both attributes exported through the rule extension into userAccountControl. that took care of it. :)