PowerShell is King – Get MDT Monitor data using the OData Feed using a PowerShell Function

I have done same blogposts that includes the usage of the MDT Monitor:

and they all use the same basic function.

During class last week I’ve got the question (You know who you are) –Is it possible to get the Dart information? and just two days later I’ve got on other question on how to extract the Step name, so, here it is a slightly updated and modified PowerShell function that will extract data from the MDT Monitor OData feed without the use of any MDT binary’s.

The updated Function:

Function Get-MDTOData{
        Function for getting MDTOdata
        Function for getting MDTOdata
        Get-MDTOData -MDTMonitorServer MDTSERVER01
        Created:	 2016-03-07
        Version:	 1.0

        Author - Mikael Nystrom
        Twitter: @mikael_nystrom
        Blog   :

    $URL = "http://" + $MDTMonitorServer + ":9801/MDTMonitorData/Computers"
    $Data = Invoke-RestMethod $URL
    foreach($property in ($ ){
        $Hash =  [ordered]@{ 
            Name = $($property.Name); 
            PercentComplete = $($property.PercentComplete.’#text’); 
            Warnings = $($property.Warnings.’#text’); 
            Errors = $($property.Errors.’#text’); 
            DeploymentStatus = $( 
                1 { "Active/Running"} 
                2 { "Failed"} 
                3 { "Successfully completed"} 
                Default {"Unknown"} 
            StepName = $($property.StepName);
            TotalSteps = $($property.TotalStepS.'#text')
            CurrentStep = $($property.CurrentStep.'#text')
            DartIP = $($property.DartIP);
            DartPort = $($property.DartPort);
            DartTicket = $($property.DartTicket);
            VMHost = $($property.VMHost.'#text');
            VMName = $($property.VMName.'#text');
            LastTime = $($property.LastTime.'#text') -replace "T"," ";
            StartTime = $($property.StartTime.’#text’) -replace "T"," "; 
            EndTime = $($property.EndTime.’#text’) -replace "T"," "; 
        New-Object PSObject -Property $Hash

And is here some examples on how you can use the data:

Pure Vanilla Commandline:

Get-MDTOData -MDTMonitorServer SRVMDT01


Using GridView

Get-MDTOData -MDTMonitorServer SRVMDT01 | Out-GridView


Create a WebPage
$Title = "ViaMonstra Deployment Status"
$Head = "<style>"
$Head = $Head + "BODY{background-color:peachpuff;}"
$Head = $Head + "TABLE{border-width: 2px;border-style: solid;border-color: black;border-collapse: collapse;}"
$Head = $Head + "TH{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:thistle}"
$Head = $Head + "TD{border-width: 1px;padding: 0px;border-style: solid;border-color: black}"
$Head = $Head + "</style>"

Get-MDTOData -MDTMonitorServer SRVMDT01 | Sort -Property Name |
ConvertTo-Html  `
-Title $Title  `
-Head $Head  `
-Body (Get-Date -UFormat "%Y-%m-%d - %T ")  `
-PreContent "<H2>$Title for: $ENV:COMPUTERNAME </H2><P>Generated by Power of the Force</P>"  `
-PostContent "<P>For details, contact</P>"  `
-Property Name,PercentComplete,Warnings,Errors,DeploymentStatus,StepName,TotalSteps,CurrentStep,DartIP,DartPort,DartTicket,VMHost,VMName,LastTime,StartTime,EndTime |
ForEach {
if($_ -like "*<td>Successfully completed</td>*"){$_ -replace "<tr>", "<tr bgcolor=green>"}
elseif($_ -like "*<td>Failed</td>*"){$_ -replace "<tr>", "<tr bgcolor=red>"}
} > C:\inetpub\wwwroot\default.htm 


You can also download and use this Module directly from by running the following command in PowerShell (version 5)

Find-Module GetMDTOdataModule | Install-Module -Scope CurrentUser


Categories: MDT, PowerShell

Tagged as: ,

7 replies »

  1. What’s the best way to make this a background process? I was going to do task scheduler but then I realized there would be a window popping up every 5 minutes.

  2. Hi Mike.

    I installed the module as instructed from the powershellgallery, but when I run Get-MDTOData -MDTMonitorServer SRVMDT01 | Out-GridView – I get:
    Get-MDTOData : The term ‘Get-MDTOData’ is not recognized as the name of a cmdlet, function, script file, or operable pr
    ogram. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    At line:1 char:1
    + Get-MDTOData -MDTMonitorServer mdt2013u1.dgi.ds | Out-GridView
    + ~~~~~~~~~~~~
    + CategoryInfo : ObjectNotFound: (Get-MDTOData:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

    Why is this?

  3. i got a nice little question for you…
    i would like to also see what the current task used is!
    i tried to find out all things you can read from this script but i fail to find something corresponding to the Tasksequence ID or whatever …

    room for improvement?

    (Something failed with my other post, i think so if this is a double-post please remove this one)

Leave a Reply

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

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

Facebook photo

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

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.