SCCM Status Message Query for Advertismet

Made a small combination of a couple of queries, so this will show “Clients That Ran, Received, Rejected or Started a Specific Advertised Program

SELECT stat.*, ins.*, att1.*, att1.AttributeTime
FROM SMS_StatusMessage AS stat
LEFT JOIN SMS_StatMsgInsStrings AS ins ON stat.RecordID = ins.RecordID
LEFT JOIN SMS_StatMsgAttributes AS att1 ON stat.RecordID = att1.RecordID
INNER JOIN SMS_StatMsgAttributes AS att2 ON stat.RecordID = att2.RecordID

WHERE
        stat.ModuleName = "SMS Client" AND
        (
                (stat.MessageID = 10005 AND att2.AttributeID = 401)  OR
                (stat.MessageID >= 10018 AND stat.MessageID <=10019 and att2.AttributeID = 401) OR
                (stat.MessageID = 10002 AND att2.AttributeID = 401) OR
                (stat.MessageID >= 10008 AND stat.MessageID <= 10009)
        )
        AND att2.AttributeValue = ##PRM:SMS_StatMsgAttributes.AttributeValue##
        AND att2.AttributeTime >= ##PRM:SMS_StatMsgAttributes.AttributeTime##
ORDER BY att1.AttributeTime DESC

Outlook inbox cleaner

I like to keep my inbox clean… so every now and then I sort out mails to different folders. That is boooring.

So I wrote a little script. :-)

Sub InboxCleaner()
    Dim oNamespace As Outlook.NameSpace
    Dim oInboxFolder As Outlook.MAPIFolder
    Dim oDestFolder As Outlook.MAPIFolder
    Dim oItem As Object
    Dim i, iMove, iNoMove As Integer
    Dim sMsg, sFolder As String
    Dim bDoMove As Boolean

    Set oNamespace = Application.GetNamespace("MAPI")
    Set oInboxFolder = oNamespace.GetDefaultFolder(olFolderInbox)

    sMsg = ""
    iNoMove = 0
    iMove = 0

    For i = oInboxFolder.Items.Count To 1 Step -1
        Set oItem = oInboxFolder.Items(i)

        If InStr(oItem.SenderEmailAddress, "@") <> 0 Then
            sFolder = oItem.SenderEmailAddress ' Get sender address
            sFolder = Right(sFolder, Len(sFolder) - InStrRev(sFolder, "@")) ' Only domain name
            sFolder = Left(sFolder, InStr(sFolder, ".") - 1) ' Skip everything after the first dot
            sFolder = UCase(Left(sFolder, 1)) & Right(sFolder, Len(sFolder) - 1) ' Upper case first letter

            On Error Resume Next
            ' This row you might want to customize... I have a folders like  Mailbox\Customers\TheCustomerName
            Set oDestFolder = oInboxFolder.Folders.Parent.Parent.Folders("Customers").Folders(sFolder)

            If Err.Number <> 0 Then
                sMsg = sMsg & "Missing folder: " & vbTab & oItem.SenderEmailAddress & "  (" & sFolder & ")" & vbCrLf
                Set oDestFolder = Nothing
                Err.Clear
                bDoMove = False
                iNoMove = iNoMove + 1
            Else
                sMsg = sMsg & "Move:           " & vbTab & oItem.SenderEmailAddress & " -> " & sFolder & vbCrLf
                bDoMove = True
                iMove = iMove + 1
            End If
            On Error GoTo 0

            If bDoMove Then
                ' Comment out this line if you only want to test
                oItem.Move oDestFolder
            End If
        End If
    Next

    sMsg = sMsg & vbCrLf & _
        vbCrLf & _
        "Processed " & oInboxFolder.Items.Count & " items in inbox..." & vbCrLf & _
        "Moved:          " & vbTab & iMove & vbCrLf & _
        "Missing folder: " & vbTab & iNoMove & vbCrLf & _
        "Skipped:        " & vbTab & (oInboxFolder.Items.Count - (iMove + iNoMove))

    MsgBox sMsg, vbOKOnly, "Inbox Cleaner / Rikard Ronnkvist / snowland.se"

End Sub

Download: inboxcleaner.vbs

Update: Screendump of the result.
090323_inboxcleaner


Bulk update commandlines in SCCM-programs

Just a small script to update the commandline of a large number of programs in SCCM.

This script will change from “/q” to “/qb!”…

Set oLocator = CreateObject("WbemScripting.SWbemLocator")
Set oSccmWmi = oLocator.ConnectServer(".", "root\sms\site_C01", "", "")

Set oPrograms = oSccmWmi.ExecQuery("select * from SMS_Program where CommandLine LIKE '%msiexec%/q %'")

For Each oProgram In oPrograms
        WScript.Echo "Package: " & oProgram.PackageID & "  (" & oProgram.ProgramName & ")"
        WScript.Echo "Orginal: " & oProgram.CommandLine

        sNewCmd = Replace(oProgram.CommandLine, "/q", "/qb!")
        WScript.Echo "    New: " & sNewCmd

        Set oModProgram = oSccmWmi.Get("SMS_Program.PackageID='" & oProgram.PackageID & "'" & ",ProgramName='" & oProgram.ProgramName & "'")
        oModProgram.CommandLine = sNewCmd
        oModProgram.Put_ ' Comment out this line if you want to test
        Set oModProgram = Nothing
Next

SCOM Alerts Severity and Priority

I don’t know why, but this information is hard to find in the docs.

Anyway, the severity and priority for alerts is mapped like this (works the same way in SCE):

Severity

  • Critical = 2
  • Warning = 1
  • Information = 0

Priority

  • High = 2
  • Medium = 1
  • Low = 0