Deployment

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

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

Categories: Deployment, MAP, PowerShell, SCCM

7 replies »

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 )

Connecting to %s

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