MDT – Deployment Query Date (VBS)

Useful script to determine when you pushed out an image from MDT…

Save the following as a *.VBS file:

Option Explicit
Const strComputer = "."
Const strNamespace = "\root\cimv2"
Const strClassName = "Microsoft_BDD_Info"

Const wbemCimTypeDatetime = 101
'Const wbemCimTypeString = 8
'Const wbemCimtypeBoolean = 11

Dim objSWbemServices: Set objSWbemServices = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & strNamespace)
Dim colInstances: Set colInstances = objSWbemServices.ExecQuery("SELECT * FROM " & strClassName)
Dim iCount, objInstance, objProperty, colProperties
Dim dateTime : Set dateTime = CreateObject("WbemScripting.SWbemDateTime")
On Error Resume Next
Dim o: o = colInstances.count
On Error Goto 0
If Not IsEmpty(o) Then
    iCount = 0
    For Each objInstance in colInstances
        iCount = iCount + 1
        Set colProperties = objInstance.Properties_
        For Each objProperty in colProperties
            If objProperty.cimType = wbemCimTypeDatetime Then
                datetime.Value = objProperty.Value
                If objProperty.Value <> "" Then WScript.Echo objProperty.Name & ": " & datetime.GetVarDate
            Else
                If objProperty.Value <> "" Then WScript.Echo objProperty.Name & ": " & objProperty.Value
            End If
        Next

    Next
Else
    WScript.Echo strClassName & " not found."
End if

Original author – Michael Klinteberg:
http://social.technet.microsoft.com/Forums/en-US/mdt/thread/e783c5ec-da83-4111-80f2-ea4539d603e2

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s