The Deployment Bunny

OS Deployment, Virtualization, Microsoft based Infrastructure…

  • Archives

  • Meta

PowerShell is King – I need to monitor OS Deployment in MDT 2012 not using Deployment Workbench

Posted by Mikael Nystrom on March 6, 2013

Scenario:

You are using MDT 2012 Update 1 (Lite Touch or Zero Touch), you have enabled MDT monitoring and you would like to know the current status of the OSD deployment, but you would like to read directly from the OData feed using PowerShell and maybe get a nice grid-view. Now, you might wonder why and that is easy, basically every blog post I have seen on this topic assumes you are logged on to the server where the MDT Workbench exists, but that is not always the case.

Solution:

Use PowerShell to get the data using the Invoke-RESTMethod, convert and read it as a Grid view

Display on screen in text

image

Display using grid view:

image

PowerShell command to execute:

You need to change MDT01 to the name of your deployment server for this to work.


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

function GetMDTData {
  $Data = Invoke-RestMethod $URL

  foreach($property in ($Data.content.properties) ) {
    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"," ";
    }
  }
}

GetMDTData | Select Name, DeploymentStatus, PercentComplete, Warnings, Errors, StartTime, EndTime | Out-GridView


Download script here:  http://sdrv.ms/WtxtnU

/mike

6 Responses to “PowerShell is King – I need to monitor OS Deployment in MDT 2012 not using Deployment Workbench”

  1. Dan said

    That’s awesome, Mike. Thanks a lot.

  2. Sem said

    This looks really great!
    Have to give it a try.

    Is there any refresh interval?

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

 
Follow

Get every new post delivered to your Inbox.

Join 3,955 other followers

%d bloggers like this: