The Deployment Bunny

OS Deployment, Virtualization, Microsoft based Infrastructure…


  • Archives

  • Meta

Nice to Know – Dumping MDT Monitor data to a Webpage (using PowerShell)

Posted by Mikael Nystrom on December 9, 2013

(update –

A customer asked me –Could you create like a web page that shows the same info as the MDT monitoring tab, so can see all the deployment all the time?, the answer is of course –Yes, of course you can!

Now, before you start barking at me and say “That could be done much easier using C#, Lisp, VB.Net” or something, this was the “My-flight-leaves-very-soon” kind of coding, so it jus a very simple PowerShell snip that runs on a 5 min schedule and create a new page and the result looks like this:


The script will read the data from the MDT monitoring feed, so the web server does not need to be on the server it self, it does not require anything at all, the script generates a HTML page and the we “modify” it on the fly and the save it in the inetpub folder, and here is the code:


And in text form:

$URL = "http://EDUDEPLOY09:9801/MDTMonitorData/Computers"

function GetMDTData { 
  $Data = Invoke-RestMethod $URL

  foreach($property in ($ ) { 
    New-Object PSObject -Property @{ 
      Name = $($property.Name); 
      PercentComplete = $($property.PercentComplete.’#text’); 
      Warnings = $($property.Warnings.’#text’); 
      Errors = $($property.Errors.’#text’); 
      DeploymentStatus = $( 
        Switch ($property.DeploymentStatus.’#text’) { 
        1 { "Active/Running" } 
        2 { "Failed" } 
        3 { "Successfully completed" } 
        Default { "Unknown" } 
      StartTime = $($property.StartTime.’#text’) -replace "T"," "; 
      EndTime = $($property.EndTime.’#text’) -replace "T"," "; 

$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>"

$Title = "LabCenter Deployment Status"

GetMDTData | Select Name, DeploymentStatus, PercentComplete, Warnings, Errors, StartTime, EndTime | Sort -Property Name |
ConvertTo-Html  `
-Title $Title  `
-Head $Head  `
-Body (Get-Date -UFormat "%Y-%m-%d - %T ")  `
-PreContent "<H2>LabCenter Deployment Status for: $ENV:COMPUTERNAME </H2><P>Generated by Power of the Force</P>"  `
-PostContent "<P>For details, contact</P>"  `
-Property Name,DeploymentStatus,PercentComplete,Warnings,Errors,StartTime |
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 
#Invoke-Item $ENV:TEMP\Default.htm

And as a download of course


23 Responses to “Nice to Know – Dumping MDT Monitor data to a Webpage (using PowerShell)”

  1. CLParker said

    Reblogged this on and commented:
    The Deployment Bunny delivers gold again!

  2. CLParker said

    Powershell Por Vida!

  3. FoxDeploy said

    This is awesome! Have you been able to throw some CSS on it to get nicer formatting?

    I could see myself using this during a deployment project.

  4. somahony73 said

    Reblogged this on Things that cross my mind… and commented:
    Love the idea of being able to give people the ability to see how a lab deployment is going without giving access to the MDT console.

  5. somahony73 said

    Is it possible to get the same type of info from config manager and output to a webpage?

  6. […]; […]

  7. […] « Nice to Know – Dumping MDT Monitor data to a Webpage (using PowerShell) […]

  8. Hi Mike, anyone,
    Can we have a step by step by step guide on where to put the ps1 file, how to configure IIS and how to view the webpage.
    Many thanks,

  9. Thats great, about to start a deployment and this would be very helpful!

  10. Shame this never happened. Anyone else know of a step by step guide?

    • Hi, sorry. The only thing you need to do is to download the POSH script, edit the URL so it points to your MDT server. When that is done, execute the powershell script using an elevated PowerShell prompt. That will give you an HTML file in the folder in the last line of the script, in my case C:\inetpub\wwwroot\default.htm. Open that with any web browser and you should be done. However, to work you do need to enable the monitor feature in MDT which is done in the Deployment Workbench (Enable Monitoring). If you would like to have the html file automatically created just create a normal scheduled tasks that runs the powershell script on a regular basis. I hope that helps, otherwise, let mw know.

  11. […] which seemed like a tedious task, then I cam across this when doing some “research”,…. Then the light bulb went off and since PowerBI is capable of pulling from a wealth of data […]

  12. John Walls said

    Great work! Thanks for the info – We’ve done a similar thing with an aspx front end to allow sorting and filtering – John

  13. Almir Ribeiro said

    Hello Master! Must permanently store the MDT monitoring information, it seems that it excludes infromações every 3 days, it is possible to permanently store?

  14. […]; […]

  15. […] Today in class, Mikael showed us this script:; […]

  16. tombullock203951218 said

    Do you think it would be possible to gather info from multiple MDT servers?

    I have a number of MDT setups and it would be great to have an overview of them all on one webpage.

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: