Month: May 2009

Repairing WMI Repository

Posted on Updated on

When troubleshooting WMI on SMS/SCCM clients, I’ve frequently used the following command to attempt a repair of the WMI repository.  I don’t recall where I found it (several years ago), but I also don’t want to ever forget it!

  1. Open a command prompt
  2. Change to directory C:\Windows\system32\wbem\
  3. Run: for /f %s in (‘dir /b *.mof *.mfl’) do mofcomp %s


HTA BackEnd Script for OSD

Posted on Updated on

This post has been updated with new code. 

Please visit OSD Options Chooser v2

There are plenty of examples out there for how to get the most out of Task Sequences for SCCM 2007 OS deployment.  But I wasn’t motivated to find out how others were doing it…Until I saw a demonstration by Jarvis Davis that he presented at MMS 2009. 

From that I built my own custom HTML Application to do what I needed.  At the moment, I have not enabled HTA support in my WinPE boot images.  So the below example is purely a “BackEnd” script which simply means that it needs to run at the towards the end of the Task Sequence so that the end-operator (or end-user) does not need to wait for much of the imaging to complete.

This HTA does the following

  • Field to enter in the name of user to add into the local Administrators group
  • Selection for US time zone to configure Windows to use (defaults to MST, since that is where I am)
  • Option to install one of 6 flavors of Adobe Acrobat
  • Option to install one of 2 flavors of Project 2003
  • Option to install one of 2 flavors of Visio 2003
  • Option to install BlackBerry desktop
  • Option to install Streets and Trips 2006

Additional things to note

  • In order to add a domain user to your local admins group, the value sDomainName = “YourDomainName” must be filled in appropriately.
  • All activity is logged into C:\CustomSystemOptions.log
  • If one of the options to install software is selected, a Task Sequence variable is created and set to True.  To utilize this, you would need to have an Install Software task that is limited to only install of the corresponding variable is set to True.  Note: the Install Software task must be after the execution of the HTA!

List Systems with Bad MIFs

Posted on Updated on

Today I was troubleshooting some client communication problems and found that one of the causes was that they were generating bad MIFs, so SCCM was rejecting the hardware inventory they were sending.  Along the way, I also found that there 230 bad MIFs on my site server.  Instead of manually opening each file to ‘document’  which system it was, I decided to script it.  I must give credit to a blog posting by Don Hite, which gave me the original idea to do this in the first place.

' AUTHOR : Nick Moseley,
' DATE   : 5/14/2009
' UPDATE : 10/29/2014 - Added code to output the SMS Unique Identifier
' COMMENT: Ensure the value for sSMSInbox is the UNC path to your SCCM inboxes
Const ForReading = 1
Dim sSMSInbox, sNamePosition, bNameFound, sFileLine, sSystemName, iFileCount, oExcel, iRow
sSMSInbox = "\\ServerName\SMS_xyz\inboxes"
Set oShell = CreateObject("WScript.Shell")
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oBadDDRFolder = oFSO.GetFolder(sSMSInbox & "\\BAD_DDRS")
Set cBadDDRFiles = oBadDDRFolder.Files
Set oBadMIFFolder = oFSO.GetFolder(sSMSInbox & "\auth\\BADMIFS")
Set colBadMIFFiles = oBadMIFFolder.Files
Set oExcel = CreateObject("Excel.Application")

' Create Excel Spreadsheet and Header
oExcel.Visible = True
Set oWorkbook = oExcel.Workbooks.Add
Set oWorksheet = oWorkbook.Worksheets(1)
iRow = 1
oExcel.Cells (iRow,1) = "System Name"
oExcel.Cells (iRow,2) = "File Name"
oExcel.Cells (iRow,3) = "File Date"
oExcel.Cells (iRow,4) = "File Size (MB)"
oExcel.Cells (iRow,5) = "SMS Unique ID"
' End Create

iFileCount = 0
For each oFile In colBadMIFFiles
    iFileCount = iFileCount + 1
    iRow = iRow + 1
    Set oMIFFile = oFSO.OpenTextFile (oFile.Path, ForReading, True)
    bNameFound = False
    Do Until bNameFound
        sFileLine = CStr (oMIFFile.ReadLine)
        sNamePosition = InStr (sFileLine, "<NetBIOS Name>")
        If sNamePosition > 1 Then
            sSystemName = Replace (Right (sFileLine, len(sFileLine) - (sNamePosition+14)), ">", "")
            sFoundBug = InStr (sSystemName, "//Client")
            If sFoundBug > 0 Then
                ' This is to fix a bug in the script which is undetermined
                ' Do Nothing
                oExcel.Cells (iRow,1) = sSystemName
                oExcel.Cells (iRow,2) = oFile.Name
                oExcel.Cells (iRow,3) = oFile.DateLastModified
                oExcel.Cells (iRow,4) = (oFile.Size/1024)/1024
                bNameFound = True
            End if
        End If
    Set oMIFFile = oFSO.OpenTextFile (oFile.Path, ForReading, True)
	bGuidFound = False
    Do Until bGuidFound
        sFileLine = CStr (oMIFFile.ReadLine)
        sNamePosition = InStr (sFileLine, "UniqueID")
        If sNamePosition > 1 Then
            sGUID = Replace (Right (sFileLine, len(sFileLine) - (sNamePosition+8)), ">", "")
                oExcel.Cells (iRow,5) = sGUID
                bGuidFound = True
        End If

oExcel.Selection.Interior.ColorIndex = 19
oExcel.Selection.Font.ColorIndex = 11
oExcel.Selection.Font.Bold = True
oExcel.Cells.HorizontalAlignment = -4131
Set oExcelRange = oWorksheet.UsedRange
Set oExcelRangeA1 = oExcel.Range("A1")
oExcelRange.Sort oExcelRangeA1, 1, , , , , , 1
WScript.Echo "File Count: " & iFileCount

Also, see a great post by Nick Aquino detailing how bad mifs come to exist –

Web Report for Software Updates Compliance

Posted on Updated on

SCCM doesn’t have a precreated report (that I can find) that quickly shows the patch compliance for a group of systems.  So I created one for myself, that I thought I’d share with every one.  To implement this, create a web report as you normally would; use the following SQL statement and remember to create a prompt with the information below that!

SQL Statement

select distinct sys.Name0, ui.BulletinID as BulletinID, ui.ArticleID as ArticleID, ui.Title as Title
from v_UpdateComplianceStatus css
join v_UpdateInfo ui on ui.CI_ID=css.CI_ID
join v_R_System sys on css.ResourceID=sys.ResourceID
join v_ClientCollectionMembers ccm on ccm.ResourceID=sys.ResourceID
where css.Status=2 and ccm.CollectionID=@CollID
order by sys.Name0, ui.ArticleID


Name: CollID
Prompt text: Collection ID
Provide a SQL statement:

begin  if (@__filterwildcard = '')
select CollectionID as CollectionID, Name as CollectionName
from v_Collection
order by Name
   select CollectionID as CollectionID, Name as CollectionName
   from v_Collection
   WHERE CollectionID like @__filterwildcard or Name like @__filterwildcard
   order by Name end

Scripting HP SoftPaqs

Posted on Updated on

Ever needed to know how to silently install an HP SoftPaq?  I recently needed to figure out the switches for approximately 75 individual SoftPaqs.  Fortunately, HP has standardized the switch to extract the setup files from the InstallShield executable.

  1. From a command line, simply call the .exe with /s to perform a silent extraction.
    Note: In some cases, no additional switches will be necessary and InstallShield will pass to the setup program the command to silently install.  If this is the case, then mark this as the only install switch you need.
  2. Change the working directory to where the files were just extracted.
  3. Do a directory list to find the name of the setup file, which will likely be Setup.exe
  4. Discover the switches that will work for that setup program.  This could be anything of the following
    • /s
    • /silent
    • -s
    • /q
    • /S /v/qn
    • /k – This is switch is very common for ATI Graphics controllers!
  5. Once you have found the silent install switches for the setup program, then you’re final switches become /s /a /SetupSwitch(es)

For BIOS related SoftPaqs, I find that it’s easiest to extract all of the files and then run HPQFlash.exe -s

MMS 2009 – Day 4 & 5

Posted on Updated on

Sorry, got a little behind in posts ;-)

My day 4 of MMS 2009 was focused on migrating to Native mode for SCCM and various SCCM implmentations in the field.  The Native mode sessions thoroughly stressed the need to have a well planned PKI environment.  Though it may be a daunting challenge to migrate with issues, I’m confident that it can be done.  It is also interesting to hear of some of the issues that existed in the field and some of the custom implementations that others are doing…they gave me some good ideas of things to potentially implement (of which I would share on this blog).

MMS day 5, a sad closing to the week.  Nothing was wrong with the day, but MMS is such a great experience and a great place to learn more on systems management that it was sad to have to end.  However, my brain was sure full and ready for a break!  Anyhow, I’ve always wondered how custom console extensions are built.  Convienantly enough, there was an actual session on it this year!  I understand the gist of what is being done, but I need to dig into it and formulize a step-by-step process for how to build them.  Again, when I am able to do this, I’ll post on this blog to share!

I never take as many pictures as I want when I’m Vegas, but here are a few from Thursday’s closing party.  Thanks to Jeremiah Beckett and everyone at Secure Vantage for sponsoring it!