Re-notify users of a alerts

This little powershell-script will update all alerts with resolutionstate “New” and an age of at least 24 hours… and with that done the users subscribing to that alert will get a new notification.

1
2
3
$UpdateAlerts = Get-Alert | where { $_.ResolutionState -eq 0 -and $_.LastModified -lt (get-date).AddHours(-24) }
 
foreach ($alert in $UpdateAlerts) { $alert.Update("Renotify operators of an untouched alert open for 24 hours") }

SCCM Console Extensions – Parameters

OK, so now you know the GUID for the right-click tool… but what about passing parameters?

There are a few standard SUB’s (parameters) that you can use, some are listed in this post: https://snowland.se/2008/05/28/sccm-console-extensions/

But if you take the example of GUID 5fb29b42-5d11-4642-a6c9-24881a7d317e that you can find under Software Distribution Packages / Packages / Some package / Package Status / Site Server / Right click on a distribution point

Say that you want to pass the server-name or the path to the package…

First off, open the E:\Program Files\Microsoft Configuration Manager\AdminUI\XmlStorage\ConsoleRoot\AdminConsole.xml in some editor.

Then search for the GUID and you will find something like this.

01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
<nodedescriptions>
  <resultpaneitemdescriptions>
    <resultpaneitemdescription namespaceguid="5fb29b42-5d11-4642-a6c9-24881a7d317e" designername="Localize:Status scoped result panel definitioN">
      <queries>
        <querydescription namespaceguid="54d25192-0e7a-47b2-a6f2-67ff764d41c6" type="WQL" helptopic="e63a41d2-a2c2-4a52-bfbb-67dc0bd7b429">
          <supportedtypes>
            <string>SMS_PackageStatusDetailSummarizer</string>
          </supportedtypes>
          <query>SELECT * FROM SMS_PackageStatusDistPointsSummarizer WHERE PackageID='##SUB:PackageID##' AND SiteCode='##SUB:SiteCode##'</query>
          <returnedclasstype>SMS_PackageStatusDistPointsSummarizer</returnedclasstype>
        </querydescription>
      </queries>
    </resultpaneitemdescription>
  </resultpaneitemdescriptions>
</nodedescriptions>

A few lines below the GUID you find SELECT * FROM SMS_PackageStatusDistPointsSummarizer WHERE Packa… Copy that line and replace/clean it up so that it is a valid WMI-query.
Will look something like:

1
SELECT * FROM SMS_PackageStatusDistPointsSummarizer WHERE PackageID='XYZ00123' AND SiteCode='XYZ'

Next step is to start some WMI-browser and connect to root\SMS\site_XYZ and run the query and take a look at the columns.
(I like to use WMI Explorer)

In the query above you will have columns like ServerNALPath, SourceNALPath, SourceVersion this is what you are looking for. :-)

Use them in your extensions like this:

1
2
3
4
<executable>
        <filepath>myScript.vbs</filepath>
        <parameters>##SUB:ServerNALPath## ##SUB:SourceNALPath## ##SUB:SourceVersion##</parameters>
</executable>

SCCM Console Extensions – Find the GUID

I wrote some about this topic in a post a while ago… did some more scripting around this today.

This VBScript will read the AdminConsole.xml and look for NameSpaceGuid’s, when it find one it will create a subdirectory (from where it is started) with the GUID and after that it will create a XML-file within that directory.
The XML-file then points to an VBS-file with a couple of parameters. (Look further down for an example of a nice VBScript to use)

Tip: Backup AdminUI\XmlStorage\Extensions\Actions before you start to play around with this.

01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
Const cVbsFile = "testExtension.vbs" ' The file to call on right-click
Const cHKEY_LOCAL_MACHINE = &H80000002
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
oReg.GetStringValue cHKEY_LOCAL_MACHINE,"SOFTWARE\Microsoft\ConfigMgr\Setup", "UI Installation Directory", sSccmPath
Set oReg = Nothing
 
sSourcePath = Replace(WScript.ScriptFullName, WScript.ScriptName, "")
 
Set oShell = CreateObject("WScript.Shell")
Set oFso = CreateObject("Scripting.FileSystemObject")
Set oFile = oFso.OpenTextFile(sSccmPath & "\XmlStorage\ConsoleRoot\AdminConsole.xml", 1)
Do While oFile.AtEndOfStream <> True
    sText = Trim(uCase(oFile.ReadLine))
    If InStr(sText, "NAMESPACEGUID=") Then
 
                ' Read the GUID from NameSpaceGuid param
                sGuid = sText
                sGuid = Right(sGuid, Len(sGuid) - InStr(sGuid, "NAMESPACEGUID=") - 14)
                sGuid = Left(sGuid, InStr(sGuid, """")-1)
 
                if not oFso.FolderExists(sSourcePath & sGuid) Then
                        WScript.Echo sSourcePath & sGuid
 
                        ' Create the GUID folder
                        oFso.CreateFolder sSourcePath & sGuid
 
                        ' Create the XML-file with current Guid, Name & ResourceID as parameter to source-VBScript
                        Set oXmlFile = oFso.CreateTextFile(oShell.ExpandEnvironmentStrings("%TEMP%\snowland-guid-locator.xml"), True)
                        oXmlFile.WriteLine "<actiondescription class="" executable="" displayname="" guid="" sguid="" mnemonicdisplayname="" locator="" description="" snowland.se="">"
                        oXmlFile.WriteLine "<executable>"
                        oXmlFile.WriteLine "<filepath>" & sSourcePath & cVbsFile & "</filepath>"
                        oXmlFile.WriteLine "<parameters>" & sGuid & " ##Sub:Name## ##Sub:ResourceID## ##SUB:ItemName## ##SUB:NetworkOSPath## ##SUB:value##</parameters>"
                        oXmlFile.WriteLine "</executable>"
                        oXmlFile.WriteLine "</actiondescription>"
                        oXmlFile.Close
 
                        ' Copy XML to GUID-directory with name "snowland-GUID.xml" as name
                        oFso.CopyFile oShell.ExpandEnvironmentStrings("%TEMP%\snowland-guid-locator.xml"), sSourcePath & sGuid & "\snowland-" & sGuid & ".xml"
                End if
        End If
Loop
oFile.Close

So… when you restarted the console you will se GUID’s showing up. To get those GUID’s to the clipboard use a testExtension.vbs like this

01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
Set oFso = CreateObject("Scripting.FileSystemObject")
Set oShell = CreateObject("WScript.Shell")
 
' Create a temporary file
Set oFile = oFso.CreateTextFile(oShell.ExpandEnvironmentStrings("%TEMP%\sccmXmlReader.tmp"), True)
 
' Loop thru arguments
For i = 0 to WScript.Arguments.Count-1
        sOut = sOut & Wscript.Arguments(i) & VbCrLf
        ' Write to file
        oFile.WriteLine Wscript.Arguments(i)
Next
' Close the file
oFile.Close
 
' Type the file to the clipboard
oShell.Run oShell.ExpandEnvironmentStrings("%SystemRoot%\System32\cmd.exe /c type %TEMP%\sccmXmlReader.tmp | %SystemRoot%\System32\clip.exe"), 1, True
 
' Delete the file
oFso.DeleteFile oShell.ExpandEnvironmentStrings("%TEMP%\sccmXmlReader.tmp"), True
 
' Send a message to the user
MsgBox sOut, vbOKOnly, "Copied to clipboard"

Will try to do a post about how to find the SUB’s…