The Deployment Bunny

OS Deployment, Virtualization, Microsoft based Infrastructure…

  • Archives

  • Meta

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

Posted by Mikael Nystrom on March 7, 2016

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


7 Responses to “PowerShell is King – Get MDT Monitor data using the OData Feed using a PowerShell Function”

  1. Mike H said

    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. Søren Elmholt said

    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. enlox said

    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 )

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

%d bloggers like this: